Esempio n. 1
0
def test_doi1():
    assert ("* {{cite journal | last=Atkins | first=Joshua H. | "
            "last2=Gershell | first2=Leland J. | title="
            "Selective anticancer drugs | journal=Nature Reviews Drug "
            "Discovery | publisher=Springer Nature | volume=1 | issue=7 | "
            "year=2002 | issn=1474-1776 | doi=10.1038/nrd842 | pages=491–492}}"
            ) == doi_scr('https://doi.org/10.1038%2Fnrd842')[1]
Esempio n. 2
0
def test_doi_isbn_no_year():
    """Test when issue date is empty."""
    assert ('* {{cite thesis | last=Ambati | first=V.R. '
            '| title=Forecasting water waves and currents :'
            ' a space-time approach '
            '| publisher=University Library/University of Twente '
            '| isbn=978-90-365-2632-6 | doi=10.3990/1.9789036526326}}'
            ) == doi_scr('10.3990/1.9789036526326')[1]
Esempio n. 3
0
def test_doi3():
    """No author. URL contains %2F."""
    assert ('* {{cite journal | last=Spitzer | first=H. F. '
            '| title=Studies in retention. '
            '| journal=Journal of Educational Psychology '
            '| publisher=American Psychological Association (APA) '
            '| volume=30 | issue=9 | year=1939 | issn=0022-0663 '
            '| doi=10.1037/h0063404 | pages=641–656}}'
            ) == doi_scr('https://doi.org/10.1037%2Fh0063404')[1]
Esempio n. 4
0
def test_doi1():
    # Note: Language detection is wrong, it should be en
    assert ("* {{یادکرد ژورنال | نام خانوادگی=Atkins |"
            " نام=Joshua H. | نام خانوادگی۲=Gershell | نام۲=Leland J. |"
            " عنوان=Selective anticancer drugs |"
            " ژورنال=Nature Reviews Drug Discovery |"
            " ناشر=Springer Nature | جلد=1 | شماره=7 |"
            " سال=2002 | issn=1474-1776 | doi=10.1038/nrd842 |"
            " صفحه=491–492 |"
            " زبان=da}}") in doi_scr('http://dx.doi.org/10.1038/nrd842')[1]
Esempio n. 5
0
def test_non_numeric_volume():
    assert ('* {{cite journal | last=Niemeyer | first=Jurgen | last2=Hinken '
            '| first2=Johann H. | last3=Kautz | first3=Richard L. '
            '| title=Near-Zero Bias Arrays of Josephson Tunnel Junctions '
            'Providing Standard Voltages up to 1 V | journal=IEEE '
            'Transactions on Instrumentation and Measurement '
            '| publisher=Institute of Electrical and Electronics Engineers '
            '(IEEE) | volume=IM-34 | issue=2 | year=1985 | issn=0018-9456 '
            '| doi=10.1109/tim.1985.4315297 | pages=185–187}}'
            ) == doi_scr('10.1109/TIM.1985.4315297')[1]
Esempio n. 6
0
def test_doi2():
    """Title of this DOI could not be detected in an older version."""
    assert (
        '* {{cite journal | title=Books of Critical Interest '
        '| journal=Critical Inquiry '
        '| publisher=University of Chicago Press | volume=40 '
        '| issue=3 | year=2014 | issn=0093-1896 | doi=10.1086/677379 '
        '| pages=272–281 '
        '| ref={{sfnref | University of Chicago Press | 2014}}'
        '}}') == doi_scr('http://www.jstor.org/stable/info/10.1086/677379')[1]
Esempio n. 7
0
def test_bad_author_name():
    assert ('* {{cite journal | last=Giusti | first=D. | last2=Lubicz '
            '| first2=V. | last3=Martinelli | first3=G. | last4=Sanfilippo '
            '| first4=F. | last5=Simula | first5=S. '
            '| title=Strange and charm HVP contributions to the muon (g − 2) '
            'including QED corrections with twisted-mass fermions '
            '| journal=Journal of High Energy Physics '
            '| publisher=Springer Nature | volume=2017 | issue=10 '
            '| year=2017 | issn=1029-8479 | doi=10.1007/jhep10(2017)157}}'
            ) == doi_scr('10.1007/JHEP10(2017)157')[1]
Esempio n. 8
0
def test_conference_location():
    """Test citing a conference with location."""
    assert ("* {{cite conference "
            "| title=Proceedings of the international workshop on System-level"
            " interconnect prediction  - SLIP'06 "
            "| publisher=ACM Press "
            "| publication-place=New York, New York, USA "
            "| year=2006 "
            "| isbn=1-59593-255-0 "
            "| doi=10.1145/1117278 "
            "| ref={{sfnref | ACM Press | 2006}}"
            "}}") == doi_scr('10.1145/1117278')[1]
Esempio n. 9
0
def test_doi4():
    """publisher=Informa {UK"""
    assert ('* {{cite journal | last=Davis | first=Margaret I. | last2=Jason '
            '| first2=Leonard A. | last3=Ferrari | first3=Joseph R. '
            '| last4=Olson | first4=Bradley D. | last5=Alvarez '
            '| first5=Josefina '
            '| title=A Collaborative Action Approach to Researching Substance'
            ' Abuse Recovery '
            '| journal=The American Journal of Drug and Alcohol Abuse '
            '| publisher=Informa UK Limited '
            '| volume=31 | issue=4 | year=2005 | issn=0095-2990 '
            '| doi=10.1081/ada-200068110 | pages=537–553}}'
            ) == doi_scr('10.1081%2Fada-200068110')[1]
Esempio n. 10
0
def test_incollection():
    """Test the `incollection` type."""
    assert (
        '* {{cite book '
        '| last=Meyer '
        '| first=Albert R. '
        '| title=Lecture Notes in Mathematics '
        '| chapter=Weak monadic second order theory of succesor is not'
        ' elementary-recursive '
        '| publisher=Springer Berlin Heidelberg '
        '| publication-place=Berlin, Heidelberg '
        '| year=1975 '
        '| isbn=978-3-540-07155-6 '
        '| issn=0075-8434 '
        '| doi=10.1007/bfb0064872}}') == doi_scr('DOI 10.1007/BFb0064872')[1]
Esempio n. 11
0
def url_doi_isbn_scr(user_input, date_format) -> tuple:
    en_user_input = unquote(uninum2en(user_input))
    # Checking the user input for dot is important because
    # the use of dotless domains is prohibited.
    # See: https://features.icann.org/dotless-domains
    if '.' in en_user_input:
        # Try predefined URLs
        # Todo: The following code could be done in threads.
        if not user_input.startswith('http'):
            url = 'http://' + user_input
        else:
            url = user_input
        parsed_url = urlparse(url)
        # TLD stands for top-level domain
        tldless_netloc = parsed_url[1].rpartition('.')[0]
        # todo: make lazy?
        resolver = TLDLESS_NETLOC_RESOLVER(
            tldless_netloc[4:] if tldless_netloc.startswith('www.')
            else tldless_netloc)
        if resolver is not None:
            if resolver is googlebooks_scr:
                return resolver(parsed_url, date_format)
            elif resolver is google_encrypted_scr:
                return resolver(url, parsed_url, date_format)
            return resolver(url, date_format)
        # DOIs contain dots
        m = DOI_SEARCH(unescape(en_user_input))
        if m is not None:
            return doi_scr(m[0], True, date_format)
        return urls_scr(url, date_format)
    else:
        # We can check user inputs containing dots for ISBNs, but probably is
        # error prone.
        m = ISBN_10OR13_SEARCH(en_user_input)
        if m is not None:
            try:
                return isbn_scr(m[0], True, date_format)
            except IsbnError:
                pass
        return UNDEFINED_INPUT_SCR