def __call__ (self, gloss): self._indent = " " self._gloss = gloss # Resolve pivotal language and environment. self._lang = self._options.lang or gloss.lang if self._lang not in gloss.languages: error(p_("error message", "language '%(lang)s' not present in the glossary") % dict(lang=self._lang)) self._env = self._options.env or gloss.env[0] if self._env and self._env not in gloss.environments: error(p_("error message", "environment '%(env)s' not defined by the glossary") % dict(env=self._env)) # Determine concepts to present and in which order. concepts = self._select_concepts() # Prepare text formatters. self._tf = TextFormatterPlain(gloss, lang=self._lang, env=self._env, escape=escape_xml) # Create TBX. accl = LineAccumulator(self._indent) self._fmt_prologue(accl) self._fmt_concepts(accl.newind(2), concepts) self._fmt_epilogue(accl) if self._options.file: tbx_fname = self._options.file else: tbx_fname = gloss.id + ".tbx" accl.write(tbx_fname)