コード例 #1
0
    def get_meta(self, key):
        prefix = self.parse_key(key)[0]
        meta = finddict(SUBJECTS, prefix=prefix)

        meta = web.storage(meta)
        meta.path = web.lstrips(key, meta.prefix)
        return meta
コード例 #2
0
ファイル: subjects.py プロジェクト: RaceList/openlibrary
    def get_meta(self, key):
        prefix = self.parse_key(key)[0]
        meta = finddict(SUBJECTS, prefix=prefix)

        meta = web.storage(meta)
        meta.path = web.lstrips(key, meta.prefix)
        return meta
コード例 #3
0
ファイル: subjects.py プロジェクト: milotype/openlibrary
 def facet_wrapper(self, facet, value, count):
     if facet == "publish_year":
         return [int(value), count]
     elif facet == "publisher_facet":
         return web.storage(name=value,
                            count=count,
                            key="/publishers/" + value.replace(" ", "_"))
     elif facet == "author_facet":
         author = read_author_facet(value)
         return web.storage(name=author[1],
                            key="/authors/" + author[0],
                            count=count)
     elif facet in [
             "subject_facet", "person_facet", "place_facet", "time_facet"
     ]:
         return web.storage(
             key=finddict(SUBJECTS, facet=facet).prefix +
             str_to_key(value).replace(" ", "_"),
             name=value,
             count=count,
         )
     elif facet == "has_fulltext":
         return [value, count]
     else:
         return web.storage(name=value, count=count)
コード例 #4
0
 def facet_wrapper(self, facet, value, count):
     if facet == "publish_year":
         return [int(value), count]
     elif facet == "publisher_facet":
         return web.storage(name=value, count=count, key="/publishers/" + value.replace(" ", "_"))
     elif facet == "author_facet":
         author = read_author_facet(value)
         return web.storage(name=author[1], key="/authors/" + author[0], count=count)
     elif facet in ["subject_facet", "person_facet", "place_facet", "time_facet"]:
         return web.storage(key=finddict(SUBJECTS, facet=facet).prefix + str_to_key(value).replace(" ", "_"), name=value, count=count)
     elif facet == "has_fulltext":
         return [value, count]
     else:
         return web.storage(name=value, count=count)
コード例 #5
0
ファイル: test_utils.py プロジェクト: yzou/openlibrary
def test_finddict():
    dicts = [{"x": 1, "y": 2}, {"x": 3, "y": 4}]
    assert finddict(dicts, x=1) == {'x': 1, 'y': 2}
コード例 #6
0
def test_finddict():
    dicts = [{'x': 1, 'y': 2}, {'x': 3, 'y': 4}]
    assert finddict(dicts, x=1) == {'x': 1, 'y': 2}
コード例 #7
0
ファイル: test_utils.py プロジェクト: RaceList/openlibrary
def test_finddict():
    dicts = [{"x": 1, "y": 2}, {"x": 3, "y": 4}]
    assert finddict(dicts, x=1) == {'x': 1, 'y': 2}