def _find_coauthors(bib):
    return set(canonical_str(a) for a in get_all_authors(bib[2]))
from invenio.dbquery import run_sql
from invenio.bibauthorid_name_utils import split_name_parts
from invenio.bibauthorid_dbinterface import get_all_authors
from invenio.bibauthorid_dbinterface import get_all_bibrecs
from bibauthorid_general_utils import update_status

print("Getting records...")
#records = [p[0] for p in run_sql("select id from bibrec")]
records = get_all_bibrecs() 
lastnames = []

for index, bibrec in enumerate(records):
    if index % 1000 == 0:
        percent = float(index) / len(records)
        update_status(percent, "%s of all %s records done." % (index, len(records)))

    for author in get_all_authors(bibrec):
        lastnames.append(split_name_parts(author)[0])

fp = open("/tmp/lastnames.txt", "w")
fp.write("\n".join(lastnames))
fp.close()
def _find_coauthors(bib):
    return set(canonical_str(a) for a in get_all_authors(bib[2]))