コード例 #1
0
ファイル: code.py プロジェクト: yzou/openlibrary
 def _do_search(self, q):
     ugly = worksearch.do_search({"q": q, "has_fulltext": "true", "public_scan": "true"}, None)
     results = web.storage({'num_found': ugly['num_found'], 'books': []})
     works = [worksearch.get_doc(doc) for doc in ugly['docs']]
     for work in works:
         work.key = '/works/%s' % work.key
     for edition, work in _editions_for_works(works):
         results['books'].append((edition, work))
     return results
コード例 #2
0
def test_get_doc():
    doc = get_doc({
        'author_key': ['OL218224A'],
        'author_name': ['Alan Freedman'],
        'cover_edition_key': 'OL1111795M',
        'edition_count': 14,
        'first_publish_year': 1981,
        'has_fulltext': True,
        'ia': ['computerglossary00free'],
        'key': '/works/OL1820355W',
        'lending_edition_s': 'OL1111795M',
        'public_scan_b': False,
        'title': 'The computer glossary',
    })
    assert doc == web.storage({
        'key':
        '/works/OL1820355W',
        'title':
        'The computer glossary',
        'url':
        '/works/OL1820355W/The_computer_glossary',
        'edition_count':
        14,
        'ia': ['computerglossary00free'],
        'collections':
        set(),
        'has_fulltext':
        True,
        'public_scan':
        False,
        'lending_edition':
        'OL1111795M',
        'lending_identifier':
        None,
        'authors': [
            web.storage({
                'key': 'OL218224A',
                'name': 'Alan Freedman',
                'url': '/authors/OL218224A/Alan_Freedman',
            })
        ],
        'first_publish_year':
        1981,
        'first_edition':
        None,
        'subtitle':
        None,
        'cover_edition_key':
        'OL1111795M',
        'languages': [],
        'id_project_gutenberg': [],
        'id_librivox': [],
        'id_standard_ebooks': [],
        'id_openstax': [],
    })
コード例 #3
0
def test_get_doc():
    sample_doc = etree.fromstring('''<doc>
<arr name="author_key"><str>OL218224A</str></arr>
<arr name="author_name"><str>Alan Freedman</str></arr>
<str name="cover_edition_key">OL1111795M</str>
<int name="edition_count">14</int>
<int name="first_publish_year">1981</int>
<bool name="has_fulltext">true</bool>
<arr name="ia"><str>computerglossary00free</str></arr>
<str name="key">OL1820355W</str>
<str name="lending_edition_s">OL1111795M</str>
<bool name="public_scan_b">false</bool>
<str name="title">The computer glossary</str>
</doc>''')

    doc = get_doc(sample_doc)
    assert doc.public_scan == False
コード例 #4
0
def test_get_doc():
    sample_doc = etree.fromstring('''<doc>
<arr name="author_key"><str>OL218224A</str></arr>
<arr name="author_name"><str>Alan Freedman</str></arr>
<str name="cover_edition_key">OL1111795M</str>
<int name="edition_count">14</int>
<int name="first_publish_year">1981</int>
<bool name="has_fulltext">true</bool>
<arr name="ia"><str>computerglossary00free</str></arr>
<str name="key">OL1820355W</str>
<str name="lending_edition_s">OL1111795M</str>
<bool name="public_scan_b">false</bool>
<str name="title">The computer glossary</str>
</doc>''')

    doc = get_doc(sample_doc)
    assert doc.public_scan == False
コード例 #5
0
ファイル: code.py プロジェクト: artmedlar/openlibrary
 def _do_search(self, q):
     ugly = worksearch.do_search({"q": q}, None)
     results = web.storage({'num_found': ugly['num_found'], 'docs': []})
     for doc in ugly['docs']:
         results['docs'].append(worksearch.get_doc(doc))
     return results