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
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)
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)
def test_finddict(): dicts = [{"x": 1, "y": 2}, {"x": 3, "y": 4}] assert finddict(dicts, x=1) == {'x': 1, 'y': 2}
def test_finddict(): dicts = [{'x': 1, 'y': 2}, {'x': 3, 'y': 4}] assert finddict(dicts, x=1) == {'x': 1, 'y': 2}