How to use refextract - 10 common examples

To help you get started, we’ve selected a few refextract examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github inspirehep / refextract / refextract / references / pdf.py View on Github external
def _destination_position(pdf, destination):
    """
    Gives a tuple (page, column, -y, x) representing the position of the
    NamedDestination

    This representation is useful for sorting named destinations and
    assumes the text has at most 2 columns
    """
    pagewidth = pdf.getPage(
        pdf.getDestinationPageNumber(destination)
    ).cropBox.lowerRight[0]
    if not destination.left or not destination.top:
        raise IncompleteCoordinatesError(destination)
    # assuming max 2 columns
    column = (2 * destination.left) // pagewidth
    return (pdf.getDestinationPageNumber(destination),
            column, -destination.top, destination.left)
github inspirehep / refextract / tests / test_regexs.py View on Github external
def test_regex_match_list():
    s = 'ABC'
    m = regexs.regex_match_list(s, [
        re.compile('C.C'),
        re.compile('A.C')
    ])
    assert m
    m = regexs.regex_match_list(s, [
        re.compile('C.C')
    ])
    assert m is None
github inspirehep / refextract / tests / test_tag.py View on Github external
def test_4_digits_suffix_version_new():
    ref_line = u"""{any prefix}9910.1234v9 [physics.ins-det]{any postfix}"""
    r = tag_arxiv(ref_line)
    assert r.strip(': ') == u"{any prefix}arXiv:9910.1234 [physics.ins-det]{any postfix}"
github inspirehep / refextract / tests / test_tag.py View on Github external
def test_4_digits_suffix_version():
    ref_line = u"""{any prefix}arXiv:1104.2222v9 [physics.ins-det]{any postfix}"""
    r = tag_arxiv(ref_line)
    assert r.strip(': ') == u"{any prefix}arXiv:1104.2222 [physics.ins-det]{any postfix}"
github inspirehep / refextract / tests / test_tag.py View on Github external
def test_5_digits_suffix_version_new_2012():
    ref_line = u"""{any prefix}1210.12345v9 [physics.ins-det]{any postfix}"""
    r = tag_arxiv(ref_line)
    assert r.strip(': ') == u"{any prefix}1210.12345v9 [physics.ins-det]{any postfix}"
github inspirehep / refextract / tests / test_tag.py View on Github external
def test_4_digits_new():
    ref_line = u"""{any prefix}9910.1234{any postfix}"""
    r = tag_arxiv(ref_line)
    assert r.strip(': ') == u"{any prefix}arXiv:9910.1234{any postfix}"
github inspirehep / refextract / tests / test_tag.py View on Github external
def test_4_digits_version_new_url():
    ref_line = u"""{any prefix}https://arxiv.org/abs/0708.0882v1{any postfix}"""
    r = tag_arxiv(ref_line)
    assert r.strip(': ') == u"{any prefix}arXiv:0708.0882{any postfix}"
github inspirehep / refextract / tests / test_tag.py View on Github external
def test_5_digits_suffix_new():
    ref_line = u"""{any prefix}1310.12345 [physics.ins-det]{any postfix}"""
    r = tag_arxiv(ref_line)
    assert r.strip(': ') == u"{any prefix}arXiv:1310.12345 [physics.ins-det]{any postfix}"
github inspirehep / refextract / tests / test_tag.py View on Github external
def test_4_digits_suffix():
    ref_line = u"""{any prefix}arXiv:1104.2222 [physics.ins-det]{any postfix}"""
    r = tag_arxiv(ref_line)
    assert r.strip(': ') == u"{any prefix}arXiv:1104.2222 [physics.ins-det]{any postfix}"
github inspirehep / refextract / tests / test_tag.py View on Github external
def test_5_digits_new_pdf_url():
    ref_line = u"""{any prefix}https://arxiv.org/pdf/1712.03976.pdf{any postfix}"""
    r = tag_arxiv(ref_line)
    assert r.strip(': ') == u"{any prefix}arXiv:1712.03976{any postfix}"