def write(self) -> "Generator[None, BaseEntry, None]": from pyglossary.text_writer import writeTxt glos = self._glos head = "" if self._writeInfo: head = ( "<header>\n" f"title = {self.getInfo('name')}\n" f"author = {self.getInfo('author')}\n" f"description = {self.getInfo('description')}\n" f"w_lang = {glos.sourceLangName}\n" f"a_lang = {glos.targetLangName}\n" "</header>\n#\n#\n#\n" ) yield from writeTxt( glos, entryFmt="{word}___{defi}\n", filename=self._filename, writeInfo=False, defiEscapeFunc=replaceStringTable([ ("\n", "<BR>"), ]), ext=".sdct", head=head, newline=self._newline, resources=self._resources, )
def write(self) -> "Generator[None, BaseEntry, None]": from json import dumps from pyglossary.text_writer import writeTxt glos = self._glos encoding = self._encoding writeInfo = self._writeInfo resources = self._resources ascii = encoding == "ascii" def escape(st): return dumps(st, ensure_ascii=ascii) yield from writeTxt( glos, entryFmt="\t{word}: {defi},\n", filename=self._filename, encoding=encoding, writeInfo=writeInfo, wordEscapeFunc=escape, defiEscapeFunc=escape, ext=".json", head="{\n", tail='\t"": ""\n}', resources=resources, )
def write(self) -> "Generator[None, BaseEntry, None]": from pyglossary.text_writer import writeTxt yield from writeTxt( self._glos, entryFmt=":{word}:{defi}\n", filename=self._filename, defiEscapeFunc=replaceStringTable([ ("\r", ""), ]), ext=".dtxt", )
def write(self) -> "Generator[None, BaseEntry, None]": from pyglossary.text_writer import writeTxt newline = self._newline resources = self._resources head = (f"###Title: {self.getInfo('title')}\n" f"###Description: {self.getInfo('description')}\n" f"###Author: {self.getAuthor()}\n" f"###Email: {self.getInfo('email')}\n" f"###Website: {self.getInfo('website')}\n" f"###Copyright: {self.getInfo('copyright')}\n") yield from writeTxt( self._glos, entryFmt="{word}\n{defi}\n\n", filename=self._filename, writeInfo=False, defiEscapeFunc=replaceStringTable([ ("\n", "<br/>"), ]), ext=".ldf", head=head, newline=newline, resources=resources, )