Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalEgn committed Aug 6, 2024
1 parent d8f4f99 commit 08b52a2
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion inspire_dojson/hep/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from __future__ import absolute_import, division, print_function

from inspire_dojson.hep.model import hep, hep2marc # noqa: F401
from inspire_dojson.hep.rules import (
from inspire_dojson.hep.rules import ( # noqa: F401
bd0xx,
bd1xx,
bd2xx,
Expand Down
16 changes: 8 additions & 8 deletions inspire_dojson/hep/rules/bd5xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def _means_not_curated(public_note):
thesis_info = self.get('thesis_info', {})

source = force_single_element(value.get('9', ''))
for value in force_list(value):
for public_note in force_list(value.get('a')):
for current_value in force_list(value):
for public_note in force_list(current_value.get('a')):
match = IS_DEFENSE_DATE.match(public_note)
if match:
try:
Expand Down Expand Up @@ -314,17 +314,17 @@ def _is_not_for_hal(value):
_private_notes = self.get('_private_notes', [])
_export_to = self.get('_export_to', {})

for value in force_list(value):
if _is_for_cds(value):
for current_value in force_list(value):
if _is_for_cds(current_value):
_export_to['CDS'] = True

if _is_for_hal(value):
if _is_for_hal(current_value):
_export_to['HAL'] = True
elif _is_not_for_hal(value):
elif _is_not_for_hal(current_value):
_export_to['HAL'] = False

source = force_single_element(value.get('9'))
for _private_note in force_list(value.get('a')):
source = force_single_element(current_value.get('9'))
for _private_note in force_list(current_value.get('a')):
_private_notes.append({
'source': source,
'value': _private_note,
Expand Down
16 changes: 8 additions & 8 deletions inspire_dojson/hepnames/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,8 @@ def _normalize(a_value):
arxiv_categories = self.get('arxiv_categories', [])
inspire_categories = self.get('inspire_categories', [])

for value in force_list(value):
for a_value in force_list(value.get('a')):
for current_value in force_list(value):
for a_value in force_list(current_value.get('a')):
normalized_a_value = _normalize(a_value)

if _is_arxiv(normalized_a_value):
Expand Down Expand Up @@ -729,14 +729,14 @@ def new_record(self, key, value):
new_record = self.get('new_record', {})
ids = self.get('ids', [])

for value in force_list(value):
for id_ in force_list(value.get('a')):
for current_value in force_list(value):
for id_ in force_list(current_value.get('a')):
ids.append({
'schema': 'SPIRES',
'value': id_,
})

new_recid = force_single_element(value.get('d', ''))
new_recid = force_single_element(current_value.get('d', ''))
if new_recid:
new_record = get_record_ref(new_recid, 'authors')

Expand All @@ -759,9 +759,9 @@ def _is_stub(value):
deleted = self.get('deleted')
stub = self.get('stub')

for value in force_list(value):
deleted = not deleted and _is_deleted(value)
stub = not stub and _is_stub(value)
for current_value in force_list(value):
deleted = not deleted and _is_deleted(current_value)
stub = not stub and _is_stub(current_value)

self['stub'] = stub
return deleted
Expand Down
12 changes: 6 additions & 6 deletions inspire_dojson/institutions/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,28 @@ def _split_acronym(value):
institution_hierarchy = self.get('institution_hierarchy', [])
related_records = self.get('related_records', [])

for value in force_list(value):
for current_value in force_list(value):
ICN.extend(force_list(value.get('t')))

if not legacy_ICN:
legacy_ICN = force_single_element(value.get('u'))
legacy_ICN = force_single_element(current_value.get('u'))

for b_value in force_list(value.get('b')):
for b_value in force_list(current_value.get('b')):
department_name, department_acronym = _split_acronym(b_value)
institution_hierarchy.append({
'acronym': department_acronym,
'name': department_name,
})

for a_value in force_list(value.get('a')):
for a_value in force_list(current_value.get('a')):
institution_name, institution_acronym = _split_acronym(a_value)
institution_hierarchy.append({
'acronym': institution_acronym,
'name': institution_name,
})

x_values = force_list(value.get('x'))
z_values = force_list(value.get('z'))
x_values = force_list(current_value.get('x'))
z_values = force_list(current_value.get('z'))

# XXX: we zip only when they have the same length, otherwise
# we might match a relation with the wrong recid.
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@

URL = "https://github.com/inspirehep/inspire-dojson"

readme = open("README.rst").read()
with open("README.rst") as f:
readme = f.read()


install_requires = [
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def test_normalize_date_aggressively_strips_wrong_month():


def test_normalize_date_aggressively_raises_on_wrong_format():
with pytest.raises(ValueError):
with pytest.raises(ValueError, match='Unknown string format: 2014=12'):
normalize_date_aggressively('2014=12-01')


Expand Down

0 comments on commit 08b52a2

Please sign in to comment.