diff --git a/inspire_dojson/hep/__init__.py b/inspire_dojson/hep/__init__.py index c503477..51e21fe 100644 --- a/inspire_dojson/hep/__init__.py +++ b/inspire_dojson/hep/__init__.py @@ -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, diff --git a/inspire_dojson/hep/rules/bd5xx.py b/inspire_dojson/hep/rules/bd5xx.py index 5005263..ff51249 100644 --- a/inspire_dojson/hep/rules/bd5xx.py +++ b/inspire_dojson/hep/rules/bd5xx.py @@ -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: @@ -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, diff --git a/inspire_dojson/hepnames/rules.py b/inspire_dojson/hepnames/rules.py index b6a3b88..16eae0c 100644 --- a/inspire_dojson/hepnames/rules.py +++ b/inspire_dojson/hepnames/rules.py @@ -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): @@ -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') @@ -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 diff --git a/inspire_dojson/institutions/rules.py b/inspire_dojson/institutions/rules.py index d422a6d..03f5821 100644 --- a/inspire_dojson/institutions/rules.py +++ b/inspire_dojson/institutions/rules.py @@ -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. diff --git a/setup.py b/setup.py index aca2dac..acd5291 100644 --- a/setup.py +++ b/setup.py @@ -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 = [ diff --git a/tests/test_utils.py b/tests/test_utils.py index 4fd5d6a..c837281 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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')