コード例 #1
0
def arxiv_syntax_validation(form, field):
    """Validate ArXiv ID syntax."""
    message = "The provided ArXiv ID is invalid - it should look \
                similar to 'hep-th/9711200' or '1207.7235'."

    if field.data and not is_arxiv(field.data):
        raise StopValidation(message)
コード例 #2
0
ファイル: simple_fields.py プロジェクト: ksachs/inspire-next
def arxiv_syntax_validation(form, field):
    """Validate ArXiv ID syntax."""
    message = "The provided ArXiv ID is invalid - it should look \
                similar to 'hep-th/9711200' or '1207.7235'."

    if field.data and not is_arxiv(field.data):
        raise StopValidation(message)
コード例 #3
0
def _is_arxiv(obj):
    """Small checker for arXiv report numbers."""
    # Workaround until this issue:
    # https://github.com/inveniosoftware/idutils/issues/14 is solved.

    arxiv_test = obj.split()
    if not arxiv_test:
        return False
    return idutils.is_arxiv(arxiv_test[0])
コード例 #4
0
ファイル: processors.py プロジェクト: michamos/inspire-next
def _is_arxiv(obj):
    """Small checker for arXiv report numbers."""
    # Workaround until this issue:
    # https://github.com/inveniosoftware/idutils/issues/14 is solved.

    arxiv_test = obj.split()
    if not arxiv_test:
        return False
    return idutils.is_arxiv(arxiv_test[0])
コード例 #5
0
def _is_arxiv(obj):
    """Return ``True`` if ``obj`` contains an arXiv identifier.

    The ``idutils`` library only handles arXiv identifiers, e.g. strings
    of the form ``arXiv:yymm.xxxxx``, but we sometimes have to deal with
    arXiv references, which might contain more information separated by
    a space. Therefore this helper wraps ``idutils`` to support this case.
    """
    arxiv_test = obj.split()
    if not arxiv_test:
        return False
    return idutils.is_arxiv(arxiv_test[0])
コード例 #6
0
ファイル: processors.py プロジェクト: fschwenn/inspire-next
def _is_arxiv(obj):
    """Return ``True`` if ``obj`` contains an arXiv identifier.

    The ``idutils`` library only handles arXiv identifiers, e.g. strings
    of the form ``arXiv:yymm.xxxxx``, but we sometimes have to deal with
    arXiv references, which might contain more information separated by
    a space. Therefore this helper wraps ``idutils`` to support this case.
    """
    arxiv_test = obj.split()
    if not arxiv_test:
        return False
    return idutils.is_arxiv(arxiv_test[0])
コード例 #7
0
def secondary_report_numbers(self, key, value):
    """Populate the ``037`` MARC field.

    Also populates the ``500``, ``595`` and ``980`` MARC field through side effects.
    """
    preliminary_results_prefixes = [
        'ATLAS-CONF-', 'CMS-PAS-', 'CMS-DP-', 'LHCB-CONF-'
    ]
    note_prefixes = [
        'ALICE-INT-', 'ATL-', 'ATLAS-CONF-', 'CMS-DP-', 'CMS-PAS-',
        'LHCB-CONF-', 'LHCB-PUB-'
    ]

    result_037 = self.get('037__', [])
    result_500 = self.get('500__', [])
    result_595 = self.get('595__', [])
    result_980 = self.get('980__', [])

    report = force_single_element(value.get('a', ''))
    hidden_report = force_single_element(value.get('9') or value.get('z', ''))
    source = 'CDS' if not is_arxiv(report) else 'arXiv'

    if any(report.upper().startswith(prefix) for prefix in note_prefixes):
        result_980.append({'a': 'NOTE'})

    if any(report.upper().startswith(prefix)
           for prefix in preliminary_results_prefixes):
        result_500.append({'9': 'CDS', 'a': 'Preliminary results'})

    is_barcode = hidden_report.startswith('P0') or hidden_report.startswith(
        'CM-P0')
    if not report.startswith('SIS-') and not is_barcode:
        result_037.append({
            '9': source,
            'a': report,
            'c': value.get('c'),
            'z': hidden_report if source == 'CDS' else None,
        })

    self['500__'] = result_500
    self['595__'] = result_595
    self['980__'] = result_980
    return result_037
コード例 #8
0
ファイル: api.py プロジェクト: inspirehep/inspirehep
def get_record_for_provided_ids(control_numbers, arxivs, dois, report_numbers):
    matched_record = (process_ids_type(control_numbers, "lit")
                      or process_ids_type(arxivs, "arxiv")
                      or process_ids_type(dois, "doi"))
    if matched_record:
        return matched_record

    for report_number in report_numbers:
        arxiv = report_number.lower().split("arxiv:")[-1]
        #  Report numbers might contain arxivs or normal report numbers
        if is_arxiv(arxiv):
            record_object = get_record_for_pid_or_none("arxiv", arxiv)
        else:
            record_object = query_report_number(report_number)
        if record_object:
            LOGGER.info(
                "Matched record by `report_number`",
                matched_number=report_number,
                record_id=record_object.id,
            )
            return record_object
    return None