diff --git a/gramps/gen/plug/docgen/treedoc.py b/gramps/gen/plug/docgen/treedoc.py index e94765740..d770f9a1b 100644 --- a/gramps/gen/plug/docgen/treedoc.py +++ b/gramps/gen/plug/docgen/treedoc.py @@ -586,6 +586,47 @@ class TreeDocBase(BaseDoc, TreeDoc): self.write_end() +#------------------------------------------------------------------------------ +# +# TreeGraphDoc +# +#------------------------------------------------------------------------------ +class TreeGraphDoc(TreeDocBase): + """ + TreeGraphDoc implementation that generates a .graph file. + """ + + def write_start(self): + """ + Write the start of the document - nothing for a graph file. + """ + pass + + def start_tree(self, option_list): + """ + Write the start of a tree - nothing for a graph file. + """ + pass + + def end_tree(self): + """ + Write the end of a tree - nothing for a graph file. + """ + pass + + def write_end(self): + """ + Write the end of the document - nothing for a graph file. + """ + pass + + def close(self): + """ Implements TreeDocBase.close() """ + TreeDocBase.close(self) + + with open(self._filename, 'w', encoding='utf-8') as texfile: + texfile.write(self._tex.getvalue()) + #------------------------------------------------------------------------------ # # TreeTexDoc @@ -653,6 +694,11 @@ if _LATEX_FOUND: 'mime' : "application/pdf", 'class': TreePdfDoc}] +FORMATS += [{'type' : "graph", + 'ext' : "graph", + 'descr': _("Graph File for genealogytree"), + 'class': TreeGraphDoc}] + FORMATS += [{'type' : "tex", 'ext' : "tex", 'descr': _("LaTeX File"),