Exemplo n.º 1
0
 def write(
     self,
     filename: str,
     dictzip: bool = False,
     install: bool = True,
 ) -> Generator[None, "BaseEntry", None]:
     from pyglossary.text_utils import runDictzip
     glos = self._glos
     filename_nox, ext = splitext(filename)
     if ext.lower() == ".index":
         filename = filename_nox
     dictdb = DictDB(filename, "write", 1)
     while True:
         entry = yield
         if entry is None:
             break
         if entry.isData():
             # does dictd support resources? and how? FIXME
             continue
         dictdb.addentry(entry.b_defi, entry.l_word)
     dictdb.finish(dosort=1)
     if dictzip:
         runDictzip(filename)
     if install:
         installToDictd(filename, dictzip,
                        glos.getInfo("name").replace(" ", "_"))
Exemplo n.º 2
0
def write(
    glos: GlossaryType,
    filename: str,
    dictzip: bool = False,
    install: bool = True,
) -> None:
    from pyglossary.text_utils import runDictzip
    (filename_nox, ext) = splitext(filename)
    if ext.lower() == ".index":
        filename = filename_nox
    dictdb = DictDB(filename, "write", 1)
    for entry in glos:
        if entry.isData():
            # does dictd support resources? and how? FIXME
            continue
        dictdb.addentry(entry.b_defi, entry.l_word)
    dictdb.finish(dosort=1)
    if dictzip:
        runDictzip(filename)
    if install:
        installToDictd(filename, dictzip,
                       glos.getInfo("name").replace(" ", "_"))