Esempio n. 1
0
    def load(self, filename):
        from pyuca.collator import COLL_ELEMENT_PATTERN, hexstrings2int # pyuca is required for ComputedCollationField

        with zipfile.ZipFile(self.zip_filename) as z:
            with z.open(filename) as f:
                for line in f:
                    line = line.split("#", 1)[0].rstrip()

                    if not line or line.startswith("@version"):
                        continue

                    a, b = line.split(";", 1)
                    char_list = hexstrings2int(a.split())
                    coll_elements = []
                    for x in COLL_ELEMENT_PATTERN.finditer(b.strip()):
                        weights = x.groups()
                        coll_elements.append(hexstrings2int(weights))
                    self.table.add(char_list, coll_elements)
Esempio n. 2
0
    def load(self, filename):
        from pyuca.collator import COLL_ELEMENT_PATTERN, hexstrings2int  # pyuca is required for ComputedCollationField

        with zipfile.ZipFile(self.zip_filename) as z:
            with z.open(filename) as f:
                for line in f:
                    line = line.split("#", 1)[0].rstrip()

                    if not line or line.startswith("@version"):
                        continue

                    a, b = line.split(";", 1)
                    char_list = hexstrings2int(a.split())
                    coll_elements = []
                    for x in COLL_ELEMENT_PATTERN.finditer(b.strip()):
                        weights = x.groups()
                        coll_elements.append(hexstrings2int(weights))
                    self.table.add(char_list, coll_elements)