示例#1
0
    def __init__(self, file_path):

        self.file_path = Path(file_path)
        if not self.file_path.exists():
            raise FileNotFoundError(self.file_path)

        with self.open_zip() as archive:
            file_names = [
                file_.filename for file_ in archive.filelist
                if not file_.is_dir()
            ]

        self.file_trie = StringTrie.fromkeys(file_names)
示例#2
0
def _get_trie(*list_replacement_items):
    replacement_items_ordereddict = OrderedDict()

    for replacement_items in list_replacement_items:
        replacement = replacement_items[0]
        items = replacement_items[1]
        replacement_items_ordereddict[replacement] = items

    trie = StringTrie(separator=' ')

    for key in replacement_items_ordereddict.keys():
        trie.update(
            StringTrie.fromkeys(replacement_items_ordereddict[key],
                                value=key,
                                separator=' '))
    return trie