def is_published(record): """Return if a record is published. We say that a record is published if it is citeable, which means that it has enough information in a ``publication_info``, or if we know its DOI and a ``journal_title``, which means it is in press. Args: record(InspireRecord): a record. Returns: bool: whether the record is published. Examples: >>> record = { ... 'dois': [ ... {'value': '10.1016/0029-5582(61)90469-2'}, ... ], ... 'publication_info': [ ... {'journal_title': 'Nucl.Phys.'}, ... ], ... } >>> is_published(record) True """ citeable = 'publication_info' in record and is_citeable(record['publication_info']) submitted = 'dois' in record and any( 'journal_title' in el for el in force_list(record.get('publication_info'))) return citeable or submitted
def is_published(record): """Return if a record is published. We say that a record is published if it is citeable, which means that it has enough information in a ``publication_info``, or if we know its DOI and a ``journal_title``, which means it is in press. Args: record(InspireRecord): a record. Returns: bool: whether the record is published. Examples: >>> record = { ... 'dois': [ ... {'value': '10.1016/0029-5582(61)90469-2'}, ... ], ... 'publication_info': [ ... {'journal_title': 'Nucl.Phys.'}, ... ], ... } >>> is_published(record) True """ citeable = 'publication_info' in record and is_citeable( record['publication_info']) submitted = 'dois' in record and any( 'journal_title' in el for el in force_list(record.get('publication_info'))) return citeable or submitted
def test_is_citeable(expected_result, formdata): assert is_citeable(formdata) is expected_result
def set_citeable(record, blob): if is_citeable(record.get('publication_info', [])): record['citeable'] = True return record