Skip to content

Commit

Permalink
aaaa
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalEgn committed Aug 6, 2024
1 parent 3efd5a1 commit 2299df0
Show file tree
Hide file tree
Showing 56 changed files with 73 additions and 118 deletions.
7 changes: 3 additions & 4 deletions inspire_dojson/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@
import re
from itertools import chain

from dojson.contrib.marc21.utils import create_record
from inspire_utils.helpers import force_list
from inspire_utils.record import get_value
from lxml.builder import E
from lxml.etree import tostring
from six import iteritems, text_type, unichr
from six.moves import urllib

from dojson.contrib.marc21.utils import create_record

from inspire_dojson.utils import create_record_from_dict, force_single_element
from inspire_utils.helpers import force_list
from inspire_utils.record import get_value

from .cds import cds2hep_marc
from .conferences import conferences
Expand Down
3 changes: 2 additions & 1 deletion inspire_dojson/cds/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
from __future__ import absolute_import, division, print_function

from itertools import chain
from inspire_utils.record import get_value

from inspire_utils.helpers import force_list
from inspire_utils.record import get_value

from ..model import FilterOverdo, clean_record

Expand Down
9 changes: 3 additions & 6 deletions inspire_dojson/cds/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,14 @@
import pycountry
import rfc3987
import six

from idutils import is_arxiv
from dojson import utils

from six.moves import urllib

from idutils import is_arxiv
from inspire_utils.helpers import force_list
from inspire_utils.name import normalize_name
from six.moves import urllib

from .model import cds2hep_marc
from ..utils import force_single_element, quote_url
from .model import cds2hep_marc

CATEGORIES = {
'Accelerators and Storage Rings': 'Accelerators',
Expand Down
7 changes: 2 additions & 5 deletions inspire_dojson/common/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@
import re
from datetime import datetime

from flask import current_app
from six.moves import urllib

from dojson import utils

from flask import current_app
from inspire_schemas.api import load_schema
from inspire_schemas.utils import classify_field
from inspire_utils.date import PartialDate, earliest_date
from inspire_utils.helpers import force_list, maybe_int
from six.moves import urllib

from ..conferences.model import conferences
from ..data.model import data
Expand All @@ -50,7 +48,6 @@
get_record_ref,
)


IS_INTERNAL_UID = re.compile(r'^(inspire:uid:)?\d{5}$')
IS_ORCID = re.compile(r'^(orcid:)?\d{4}-\d{4}-\d{4}-\d{3}[0-9X]$')

Expand Down
2 changes: 1 addition & 1 deletion inspire_dojson/conferences/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from __future__ import absolute_import, division, print_function

from ..model import FilterOverdo, add_schema, add_collection, clean_record
from ..model import FilterOverdo, add_collection, add_schema, clean_record


def remove_lone_series_number(record, blob):
Expand Down
7 changes: 3 additions & 4 deletions inspire_dojson/conferences/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@
from __future__ import absolute_import, division, print_function

from dojson import utils
from inspire_utils.helpers import force_list, maybe_float, maybe_int

from inspire_utils.helpers import force_list, maybe_int, maybe_float

from .model import conferences
from ..utils import force_single_element
from ..utils.geo import parse_conference_address
from .model import conferences


def _trim_date(date):
Expand Down Expand Up @@ -107,7 +106,7 @@ def contact_details(self, key, value):
# XXX: we zip only when they have the same length, otherwise
# we might match an email with the wrong name.
if len(m_values) == len(p_values):
for m_value, p_value in zip(m_values, p_values):
for m_value, p_value in zip(m_values, p_values, strict=False):
result.append({
'email': m_value,
'name': p_value,
Expand Down
3 changes: 1 addition & 2 deletions inspire_dojson/data/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@

from __future__ import absolute_import, division, print_function

from ..model import FilterOverdo, add_schema, add_collection, clean_record

from ..model import FilterOverdo, add_collection, add_schema, clean_record

filters = [
add_schema('data.json'),
Expand Down
2 changes: 1 addition & 1 deletion inspire_dojson/data/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
from dojson import utils
from idutils import normalize_doi

from .model import data
from ..utils import force_single_element, get_record_ref
from .model import data


@data.over('dois', '^0247.')
Expand Down
4 changes: 1 addition & 3 deletions inspire_dojson/experiments/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@

from dojson import utils
from dojson.errors import IgnoreKey

from inspire_utils.date import normalize_date
from inspire_utils.helpers import force_list, maybe_int

from .model import experiments
from ..utils import force_single_element, get_record_ref

from .model import experiments

EXPERIMENT_CATEGORIES_MAP = \
{'1': 'Collider Experiments',
Expand Down
2 changes: 1 addition & 1 deletion inspire_dojson/hep/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from __future__ import absolute_import, division, print_function

from .model import hep, hep2marc # noqa: F401
from .rules import ( # noqa: F401
bd0xx,
bd1xx,
Expand All @@ -36,4 +37,3 @@
bd9xx,
bdFFT,
)
from .model import hep, hep2marc # noqa: F401
3 changes: 1 addition & 2 deletions inspire_dojson/hep/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@
import itertools

import six

from inspire_schemas.builders.literature import is_citeable
from inspire_schemas.utils import (
convert_old_publication_info_to_new,
normalize_arxiv_category,
)
from inspire_schemas.builders.literature import is_citeable
from inspire_utils.helpers import force_list
from inspire_utils.record import get_value

Expand Down
5 changes: 1 addition & 4 deletions inspire_dojson/hep/rules/bd0xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,14 @@
from collections import defaultdict

import pycountry

from dojson import utils
from idutils import is_arxiv_post_2007, is_doi, is_handle, normalize_doi

from inspire_schemas.api import load_schema
from inspire_schemas.utils import normalize_arxiv_category
from inspire_utils.helpers import force_list

from ..model import hep, hep2marc
from ...utils import force_single_element, normalize_isbn

from ..model import hep, hep2marc

RE_LANGUAGE = re.compile(r'\/| or | and |,|=|\s+')

Expand Down
6 changes: 2 additions & 4 deletions inspire_dojson/hep/rules/bd1xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@
import re

from dojson import utils

from inspire_utils.dedupers import dedupe_list
from inspire_utils.helpers import force_list, maybe_int

from ..model import hep, hep2marc
from ...utils import (
force_single_element,
get_record_ref,
)

from ..model import hep, hep2marc

ORCID = re.compile(r'\d{4}-\d{4}-\d{4}-\d{3}[0-9Xx]')

Expand All @@ -51,7 +49,7 @@ def _get_affiliations(value):
# XXX: we zip only when they have the same length, otherwise
# we might match a value with the wrong recid.
if len(u_values) == len(z_values):
for u_value, z_value in zip(u_values, z_values):
for u_value, z_value in zip(u_values, z_values, strict=False):
result.append({
'record': get_record_ref(z_value, 'institutions'),
'value': u_value,
Expand Down
4 changes: 1 addition & 3 deletions inspire_dojson/hep/rules/bd2xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@
from __future__ import absolute_import, division, print_function

import langdetect

from dojson import utils

from inspire_utils.helpers import force_list

from ..model import hep, hep2marc
from ...utils import normalize_date_aggressively
from ..model import hep, hep2marc


@hep.over('titles', '^(210|245|246|247)..')
Expand Down
2 changes: 1 addition & 1 deletion inspire_dojson/hep/rules/bd3xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

from inspire_utils.helpers import maybe_int

from ..model import hep, hep2marc
from ...utils import force_single_element
from ..model import hep, hep2marc


@hep.over('number_of_pages', '^300..')
Expand Down
6 changes: 2 additions & 4 deletions inspire_dojson/hep/rules/bd5xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@
import re

from dojson import utils

from inspire_utils.date import normalize_date
from inspire_utils.helpers import force_list, maybe_int

from ..model import hep, hep2marc
from ...utils import force_single_element, get_record_ref

from ..model import hep, hep2marc

IS_DEFENSE_DATE = re.compile('Presented (on )?(?P<defense_date>.*)', re.IGNORECASE)

Expand Down Expand Up @@ -116,7 +114,7 @@ def _get_institutions(value):
'curated_relation': True,
'name': c_value,
'record': get_record_ref(z_value, 'institutions'),
} for c_value, z_value in zip(c_values, z_values)]
} for c_value, z_value in zip(c_values, z_values, strict=False)]

thesis_info = self.get('thesis_info', {})

Expand Down
6 changes: 2 additions & 4 deletions inspire_dojson/hep/rules/bd6xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@
from __future__ import absolute_import, division, print_function

import six

from dojson import utils

from inspire_utils.helpers import force_list

from ..model import hep, hep2marc
from ...utils import force_single_element, get_record_ref
from ..model import hep, hep2marc

ENERGY_RANGES_MAP = {
'1': '0-3 GeV',
Expand Down Expand Up @@ -64,7 +62,7 @@ def accelerator_experiments(self, key, value):
# XXX: we zip only when they have the same length, otherwise
# we might match a value with the wrong recid.
if len(e_values) == len(zero_values):
for e_value, zero_value in zip(e_values, zero_values):
for e_value, zero_value in zip(e_values, zero_values, strict=False):
result.append({
'legacy_name': e_value,
'record': get_record_ref(zero_value, 'experiments'),
Expand Down
3 changes: 1 addition & 2 deletions inspire_dojson/hep/rules/bd7xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from __future__ import absolute_import, division, print_function

from dojson import utils

from inspire_schemas.api import load_schema
from inspire_schemas.utils import (
convert_new_publication_info_to_old,
Expand All @@ -34,13 +33,13 @@
)
from inspire_utils.helpers import force_list, maybe_int

from ..model import hep, hep2marc
from ...utils import (
force_single_element,
get_recid_from_ref,
get_record_ref,
normalize_isbn,
)
from ..model import hep, hep2marc


@hep.over('collaborations', '^710..')
Expand Down
3 changes: 1 addition & 2 deletions inspire_dojson/hep/rules/bd9xx.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

from dojson import utils
from idutils import is_arxiv_post_2007

from inspire_schemas.api import ReferenceBuilder, load_schema
from inspire_schemas.utils import (
build_pubnote,
Expand All @@ -38,8 +37,8 @@
from inspire_utils.helpers import force_list, maybe_int
from inspire_utils.record import get_value

from ..model import hep, hep2marc
from ...utils import force_single_element, get_recid_from_ref, get_record_ref
from ..model import hep, hep2marc

COLLECTIONS_MAP = {
'babar-analysisdocument': 'BABAR Analysis Documents',
Expand Down
3 changes: 1 addition & 2 deletions inspire_dojson/hep/rules/bdFFT.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
import re

from dojson import utils

from inspire_utils.helpers import force_list

from ..model import hep, hep2marc
from ...utils import absolute_url, afs_url, afs_url_to_path
from ..model import hep, hep2marc


@hep.over('documents', '^FFT[^%][^%]')
Expand Down
3 changes: 1 addition & 2 deletions inspire_dojson/hepnames/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@

from __future__ import absolute_import, division, print_function

from ..model import FilterOverdo, add_schema, add_collection, clean_marc, clean_record

from ..model import FilterOverdo, add_collection, add_schema, clean_marc, clean_record

hepnames_filters = [
add_schema('authors.json'),
Expand Down
Loading

0 comments on commit 2299df0

Please sign in to comment.