Exemplo n.º 1
0
def earliest_date(sender, *args, **kwargs):
    """Find and assign the earliest date to a HEP paper."""
    dates = []

    if 'preprint_date' in sender:
        dates.append(sender['preprint_date'])

    if 'thesis' in sender:
        if 'date' in sender['thesis']:
            dates.append(sender['thesis']['date'])
        if 'defense_date' in sender['thesis']:
            dates.append(sender['thesis']['defense_date'])

    if 'publication_info' in sender:
        for publication_info_key in sender['publication_info']:
            if 'year' in publication_info_key:
                dates.append(publication_info_key['year'])

    if 'creation_modification_date' in sender:
        for date in sender['creation_modification_date']:
            if 'creation_date' in date:
                dates.append(date['creation_date'])

    if 'imprints' in sender:
        for imprint in sender['imprints']:
            if 'date' in imprint:
                dates.append(imprint['date'])

    earliest_date = create_earliest_date(dates)
    if earliest_date:
        sender['earliest_date'] = earliest_date
Exemplo n.º 2
0
def earliest_date(sender, *args, **kwargs):
    """Find and assign the earliest date to a HEP paper."""
    dates = []

    if 'preprint_date' in sender:
        dates.append(sender['preprint_date'])

    if 'thesis' in sender:
        for thesis_key in sender['thesis']:
            if 'date' in thesis_key:
                dates.append(thesis_key['date'])
            if 'defense_date' in thesis_key:
                dates.append(thesis_key['defense_date'])

    if 'publication_info' in sender:
        for publication_info_key in sender['publication_info']:
            if 'year' in publication_info_key:
                dates.append(publication_info_key['year'])

    if 'creation_modification_date' in sender:
        for date in sender['creation_modification_date']:
            if 'creation_date' in date:
                dates.append(date['creation_date'])

    if 'imprints' in sender:
        for imprint in sender['imprints']:
            if 'date' in imprint:
                dates.append(imprint['date'])

    earliest_date = create_earliest_date(dates)
    if earliest_date:
        sender['earliest_date'] = earliest_date
Exemplo n.º 3
0
def earliest_date(sender, json, *args, **kwargs):
    """Find and assign the earliest date to a HEP paper."""
    date_paths = [
        'preprint_date',
        'thesis_info.date',
        'thesis_info.defense_date',
        'publication_info.year',
        'legacy_creation_date',
        'imprints.date',
    ]

    dates = list(chain.from_iterable(
        [force_list(get_value(json, path)) for path in date_paths]))

    earliest_date = create_earliest_date(dates)
    if earliest_date:
        json['earliest_date'] = earliest_date
Exemplo n.º 4
0
def earliest_date(sender, json, *args, **kwargs):
    """Find and assign the earliest date to a HEP paper."""
    date_paths = [
        'preprint_date',
        'thesis_info.date',
        'thesis_info.defense_date',
        'publication_info.year',
        'legacy_creation_date',
        'imprints.date',
    ]

    dates = list(
        chain.from_iterable(
            [force_list(get_value(json, path)) for path in date_paths]))

    earliest_date = create_earliest_date(dates)
    if earliest_date:
        json['earliest_date'] = earliest_date
Exemplo n.º 5
0
def test_create_earliest_date():
    """TODO."""
    assert create_earliest_date([1877, '2002-01-05']) == '1877'
    assert create_earliest_date(['1877-02-03', '1877']) == '1877-02-03'
def test_create_earliest_date():
    """TODO."""
    assert create_earliest_date([1877, '2002-01-05']) == '1877'
    assert create_earliest_date(['1877-02-03', '1877']) == '1877-02-03'
Exemplo n.º 7
0
def test_create_earliest_date():
    """Test the date validator that excepts list."""
    assert create_earliest_date([1877, '2002-01-05']) == '1877'
    assert create_earliest_date(['1877-02-03', '1877']) == '1877-02-03'