Example #1
0
def test_is4():
    """unpure isbn10 not found in ottobib"""
    assert ('* {{cite book | last=حافظ | first=شمس‌الدین‌محمد '
            '| others=رضا نظرزاده (به‌اهتمام) '
            '| title=دیوان کامل حافظ همراه با فالنامه | publisher=دیوان '
            '| publication-place=قم - قم | year=1385 | isbn=964-92962-6-3 '
            '| language=fa}}') == isbn_scr('choghondar 964-92962-6-3 شلغم')[1]
Example #2
0
def test_is3():
    """exists in both"""
    assert ('* {{cite book | last=Sipihrī | first=Suhrāb '
            '| title=Rāz-i gul-i surkh '
            '| publisher=Muʼassasah-ʼi Intishārāt-i Nigāh '
            '| publication-place=Tihrān | year=1379 | isbn=964-6736-34-3 '
            '| oclc=53446327}}') == isbn_scr('964-6736-34-3 ')[1]
Example #3
0
def test_isbn_unpure_input():
    assert ('* {{یادکرد کتاب | نام خانوادگی=حافظ |'
            ' نام=شمس‌الدین‌محمد | دیگران=رضا نظرزاده (به‌اهتمام) |'
            ' عنوان=دیوان کامل حافظ همراه با فالنامه |'
            ' ناشر=دیوان | مکان=قم - قم |'
            ' سال=۱۳۸۵ | شابک=964-92962-6-3 | زبان=fa}}'
            ) == isbn_scr('choghondar 964-92962-6-3 شلغم')[1]
Example #4
0
def test_isbn_exists_on_ottobib_not_ketabir():
    assert ('* {{یادکرد کتاب | نام خانوادگی=Adkins | نام=Roy |'
            ' عنوان=The war for all the oceans : '
            'from Nelson at the Nile to Napoleon at Waterloo |'
            ' ناشر=Abacus | مکان=London | سال=2007 |'
            ' شابک=978-0-349-11916-8 '
            '| oclc=137313052 '
            '| زبان=en}}') in isbn_scr('9780349119168', pure=True)[1]
Example #5
0
 def test_is4(self):
     """unpure isbn10"""
     self.assertEqual(
         '* {{یادکرد کتاب | نام خانوادگی=حافظ |'
         ' نام=شمس‌الدین‌محمد | دیگران=رضا نظرزاده (به‌اهتمام) |'
         ' عنوان=دیوان کامل حافظ همراه با فالنامه |'
         ' ناشر=دیوان | مکان=قم - قم |'
         ' سال=۱۳۸۵ | ماه=۰۹ | شابک=964-92962-6-3 | زبان=fa}}',
         isbn_scr('choghondar 964-92962-6-3 شلغم')[1]
     )
Example #6
0
 def test_is3(self):
     """exists in both"""
     self.assertEqual(
         '* {{یادکرد کتاب |'
         ' دیگران=سهراب سپهری (شاعر) و سحر معصومی (به‌اهتمام) |'
         ' عنوان=راز گل سرخ: نقد و گزیده شعرهای سهراب سپهری |'
         ' ناشر=موسسه انتشارات نگاه | مکان=تهران - تهران |'
         ' سال=۱۳۸۱ | ماه=۰۶ | شابک=964-6736-34-3 | oclc=53446327 '
         '| زبان=fa}}',
         isbn_scr('964-6736-34-3 ')[1],
     )
Example #7
0
 def test_is2(self):
     """not found in ottobib"""
     self.assertEqual(
         '* {{یادکرد کتاب | دیگران=بدیل‌بن‌علی خاقانی'
         ' (شاعر)، جهانگیر منصور (به‌اهتمام) '
         'و محمدحسن فروزانفر (مقدمه) |'
         ' عنوان=دیوان خاقانی شروانی |'
         ' ناشر=موسسه انتشارات نگاه | مکان=تهران - تهران |'
         ' سال=۱۳۹۶ | ماه=۰۵ | شابک=978-964-6736-71-9 | زبان=fa}}',
         isbn_scr('978-964-6736-71-9', pure=True)[1]
     )
Example #8
0
 def test_is1(self):
     """not found in ketabir"""
     self.assertIn(
         '* {{یادکرد کتاب | نام خانوادگی=Adkins | نام=Roy |'
         ' عنوان=The war for all the oceans : '
         'from Nelson at the Nile to Napoleon at Waterloo |'
         ' ناشر=Abacus | مکان=London | سال=2007 |'
         ' شابک=978-0-349-11916-8 '
         '| oclc=137313052 '
         '| زبان=en}}',
         isbn_scr('9780349119168', pure=True)[1])
Example #9
0
 def test_is2(self):
     """not found in ottobib"""
     self.assertEqual(
         '* {{cite book | others=بدیل‌بن‌علی خاقانی (شاعر)'
         ', جهانگیر منصور (به‌اهتمام), and محمدحسن فروزانفر (مقدمه) '
         '| title=دیوان خاقانی شروانی | publisher=موسسه انتشارات نگاه '
         '| publication-place=تهران - تهران | year=1396 '
         '| isbn=978-964-6736-71-9 | language=fa | ref={{sfnref '
         '| موسسه انتشارات نگاه |'
         ' 1396}}}}',
         isbn_scr('978-964-6736-71-9', pure=True)[1]
     )
Example #10
0
def test_is1():
    """not found in ketabir"""
    assert ('* {{cite book '
            '| last=Adkins '
            '| first=Roy '
            '| title=The war for all the oceans : '
            'from Nelson at the Nile to Napoleon at Waterloo '
            '| publisher=Abacus '
            '| publication-place=London '
            '| year=2007 '
            '| isbn=978-0-349-11916-8 '
            '| oclc=137313052}}') == isbn_scr('9780349119168', pure=True)[1]
Example #11
0
def test_is2():
    """not found in ottobib"""
    assert ('* {{cite book '
            '| others=بدیل\u200cبن\u200cعلی خاقانی (شاعر), جهانگیر منصور '
            '(به\u200cاهتمام), and محمدحسن فروزانفر (مقدمه) '
            '| title=دیوان خاقانی شروانی '
            '| publisher=موسسه انتشارات نگاه '
            '| publication-place=تهران - تهران '
            '| year=1396 '
            '| isbn=978-964-6736-71-9 '
            '| oclc=1176150182 '
            '| language=fa | ref={{sfnref | موسسه انتشارات نگاه | 1396}}'
            '}}') == isbn_scr('978-964-6736-71-9', pure=True)[1]
Example #12
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
Example #13
0
def test_isbn_exists_on_ketabir_and_ottobib():
    assert (
        '* {{یادکرد کتاب | دیگران=سهراب سپهری (شاعر) و سحر معصومی (به\u200cاهتمام) | عنوان=راز گل سرخ: نقد و گزیده شعرهای سهراب سپهری | ناشر=موسسه انتشارات نگاه | مکان=تهران - تهران | سال=۱۳۸۱ | شابک=964-6736-34-3 | oclc=53446327 | زبان=fa}}'
    ) == isbn_scr('964-6736-34-3 ')[1]
Example #14
0
def test_isbn_exists_on_ketabir_not_ottobib():
    assert (
        '* {{یادکرد کتاب | دیگران=بدیل\u200cبن\u200cعلی خاقانی (شاعر)، جهانگیر منصور (به\u200cاهتمام) و محمدحسن فروزانفر (مقدمه) | عنوان=دیوان خاقانی شروانی | ناشر=موسسه انتشارات نگاه | مکان=تهران - تهران | سال=۱۳۹۶ | شابک=978-964-6736-71-9 | oclc=1176150182 | زبان=fa}}'
    ) == isbn_scr('978-964-6736-71-9', pure=True)[1]