def test_preprint_date_normalizes_date(): builder = LiteratureBuilder() builder.add_preprint_date('12 April 2010') result = builder.record['preprint_date'] expected = '2010-04-12' assert expected == result
def build_literature(self, data): literature = LiteratureBuilder() literature.add_document_type(data["document_type"]) literature.add_arxiv_eprint(data.get("arxiv_id"), data.get("arxiv_categories")) literature.add_preprint_date(data.get("preprint_date")) literature.add_doi(data.get("doi")) pdf_link = data.get("pdf_link") additional_link = data.get("additional_link") if pdf_link and "arxiv.org" not in pdf_link: literature.add_url(data.get("pdf_link")) if additional_link and "arxiv.org" not in additional_link: literature.add_url(data.get("additional_link")) literature.add_title(data["title"], source="submitter") language = data.get("language") literature.add_language(language if language != "en" else None) literature.add_inspire_categories(data.get("subjects")) for author in data.get("authors", []): record_author = literature.make_author( author.get("full_name"), record=author.get("record"), affiliations=[author.get("affiliation") ], # TODO: use `affiliation_record` ) literature.add_author(record_author) literature.add_collaboration(data.get("collaboration")) literature.add_accelerator_experiment( data.get("experiment"), record=data.get("experiment_record")) # TODO: source=submitter? literature.add_abstract(data.get("abstract"), source="submitter") for report_number in data.get("report_numbers", []): literature.add_report_number(report_number, source="submitter") page_start, page_end, artid = split_page_artid(data.get("page_range")) literature.add_publication_info( journal_title=data.get("journal_title"), journal_volume=data.get("volume"), journal_issue=data.get("issue"), journal_record=data.get("journal_record"), conference_record=data.get("conference_record"), artid=artid, page_start=data.get("start_page") or page_start, page_end=data.get("end_page") or page_end, year=data.get("year"), parent_record=data.get("parent_book_record"), ) literature.add_book_series(data.get("series_title")) literature.add_book( date=data.get("publication_date"), publisher=data.get("publisher"), place=data.get("publication_place"), ) literature.add_thesis( defense_date=data.get("defense_date"), degree_type=data.get("degree_type"), institution=data.get("institution"), date=data.get("submission_date"), ) for supervisor in data.get("supervisors", []): record_supervisor = literature.make_author( supervisor.get("full_name"), affiliations=[supervisor.get("affiliation")], roles=["supervisor"], ) literature.add_author(record_supervisor) literature.add_private_note(data.get("comments"), source="submitter") literature.add_private_note(data.get("proceedings_info"), source="submitter") if data.get("conference_record") is None: literature.add_private_note(data.get("conference_info"), source="submitter") return literature.record