def build_index(basename, relnames): """ Build a list of IndexEntry by hand, useful as a test helper for index testing. Files have no subitems, meta content is reduced to required keys. """ files = [(IndexEntry(relname, CompositeName(NAMESPACE_DEFAULT, NAME_EXACT, '/'.join((basename, relname))), Item.create('/'.join((basename, relname))).meta)) for relname in relnames] return [(IndexEntry(f.relname, f.fullname, {key: f.meta[key] for key in (CONTENTTYPE, ITEMTYPE)})) for f in files]
def build_dirs_index(basename, relnames): """ Build a list of IndexEntry by hand, useful as a test helper for index testing. Dirs are files with subitems and have meta == {}. """ return [(IndexEntry(relname, CompositeName(NAMESPACE_DEFAULT, NAME_EXACT, '/'.join((basename, relname))), {})) for relname in relnames]
def build_index(basename, relnames): """ Build a list of IndexEntry by hand, useful as a test helper. """ return [(IndexEntry( relname, CompositeName(NAMESPACE_DEFAULT, NAME_EXACT, '/'.join( (basename, relname))), Item.create('/'.join((basename, relname))).meta)) for relname in relnames]
def get_files(self): check_itemid(self) if self.meta.get(ITEMID) and self.meta.get(NAME): refers_to = self.meta[ITEMID] prefix = self.meta[ITEMID] + '/' else: refers_to = self.fqname.value prefix = self.fqname.value + '/' query = And([Term(WIKINAME, app.cfg.interwikiname), Term(REFERS_TO, refers_to), Term(ELEMENT, u'file')]) revs = flaskg.storage.search(query, limit=None) files = [] for rev in revs: names = rev.meta[NAME] for name in names: relname = name[len(prefix):] file_fqname = CompositeName(rev.meta[NAMESPACE], ITEMID, rev.meta[ITEMID]) files.append(IndexEntry(relname, file_fqname, rev.meta)) return files