details:   https://code.tryton.org/relatorio/commit/ac8bd2dc3064
branch:    default
user:      Cédric Krier <[email protected]>
date:      Sat Mar 21 16:46:15 2026 +0100
description:
        Remove support for PDF template

        Closes #75
diffstat:

 CHANGELOG                       |   1 +
 examples/basic.tex              |  21 --------------
 examples/demo_context.py        |  16 -----------
 pyproject.toml                  |   4 +-
 relatorio/templates/__init__.py |   2 +-
 relatorio/templates/pdf.py      |  58 -----------------------------------------
 6 files changed, 4 insertions(+), 98 deletions(-)

diffs (143 lines):

diff -r 42496f85b9e8 -r ac8bd2dc3064 CHANGELOG
--- a/CHANGELOG Fri Apr 03 23:49:33 2026 +0200
+++ b/CHANGELOG Sat Mar 21 16:46:15 2026 +0100
@@ -1,3 +1,4 @@
+* Remove support for PDF
 
 Version 0.12.1 - 2026-04-03
 ---------------------------
diff -r 42496f85b9e8 -r ac8bd2dc3064 examples/basic.tex
--- a/examples/basic.tex        Fri Apr 03 23:49:33 2026 +0200
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-\enableregime [utf-8]
-\mainlanguage [fr]
-
-\starttext
-
-Dear $o.customer.name,
-
-Here is the list of your purchases:
-
-\starttable[|l|l|l|l|l|]
-\HL
-\NC Name \VL Reference \VL Quantity \VL Unit Price \VL Amount \SR
-\HL
-{% for line in o.lines%} \
-\NC $line.item.name \VL $line.item.reference \VL $line.quantity
-\VL $line.item.price \VL $line.amount \SR
-\HL \
-{% end %}
-\stoptable
-
-\stoptext
diff -r 42496f85b9e8 -r ac8bd2dc3064 examples/demo_context.py
--- a/examples/demo_context.py  Fri Apr 03 23:49:33 2026 +0200
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-
-from os.path import abspath, dirname, join
-
-# test data
-from common import inv
-
-from relatorio import Report
-
-# PDF
-if __name__ == '__main__':
-    print("generating output_basic.pdf... ", end='')
-    report = Report(abspath(join(dirname(__file__), 'basic.tex')),
-        'application/pdf')
-    content = report(o=inv).render().getvalue()
-    open(join(dirname(__file__), 'output_basic.pdf'), 'wb').write(content)
-    print("done")
diff -r 42496f85b9e8 -r ac8bd2dc3064 pyproject.toml
--- a/pyproject.toml    Fri Apr 03 23:49:33 2026 +0200
+++ b/pyproject.toml    Sat Mar 21 16:46:15 2026 +0100
@@ -13,11 +13,11 @@
 maintainers = [
     {name = "Tryton", email = "[email protected]"},
     ]
-description = "A templating library able to output odt and pdf files"
+description = "A templating library able to output odt files"
 readme = 'README.rst'
 license = 'GPL-3.0-or-later'
 license-files = ['LICENSE', 'COPYRIGHT']
-keywords = ["templating", "OpenDocument", "PDF"]
+keywords = ["templating", "OpenDocument"]
 classifiers = [
     "Development Status :: 5 - Production/Stable",
     "Intended Audience :: Developers",
diff -r 42496f85b9e8 -r ac8bd2dc3064 relatorio/templates/__init__.py
--- a/relatorio/templates/__init__.py   Fri Apr 03 23:49:33 2026 +0200
+++ b/relatorio/templates/__init__.py   Sat Mar 21 16:46:15 2026 +0100
@@ -1,6 +1,6 @@
 # This file is part of relatorio.  The COPYRIGHT file at the top level of
 # this repository contains the full copyright notices and license terms.
-plugins = ['base', 'opendocument', 'pdf', 'chart']
+plugins = ['base', 'opendocument', 'chart']
 
 for name in plugins:
     __import__('relatorio.templates.%s' % name)
diff -r 42496f85b9e8 -r ac8bd2dc3064 relatorio/templates/pdf.py
--- a/relatorio/templates/pdf.py        Fri Apr 03 23:49:33 2026 +0200
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-# This file is part of relatorio.  The COPYRIGHT file at the top level of
-# this repository contains the full copyright notices and license terms.
-import os
-import shutil
-import subprocess
-import tempfile
-from io import BytesIO
-
-import genshi
-import genshi.output
-from genshi.template import NewTextTemplate
-
-from relatorio.reporting import MIMETemplateLoader
-from relatorio.templates.base import RelatorioStream
-
-__metaclass__ = type
-
-TEXEXEC = 'texexec'
-_encode = genshi.output.encode
-
-
-class Template(NewTextTemplate):
-
-    def generate(self, *args, **kwargs):
-        generated = super(Template, self).generate(*args, **kwargs)
-        return RelatorioStream(generated, PDFSerializer())
-
-
-class PDFSerializer:
-
-    def __init__(self):
-        self.text_serializer = genshi.output.TextSerializer()
-
-    def __call__(self, stream, method=None, encoding='utf-8', out=None):
-        if out is None:
-            result = BytesIO()
-        else:
-            result = out
-        working_dir = tempfile.mkdtemp(prefix='relatorio')
-        tex_file = os.path.join(working_dir, 'report.tex')
-        pdf_file = os.path.join(working_dir, 'report.pdf')
-
-        with open(tex_file, 'w') as fp:
-            fp.write(_encode(self.text_serializer(stream)))
-
-        subprocess.check_call([TEXEXEC, '--purge', 'report.tex'],
-                              cwd=working_dir)
-
-        with open(pdf_file, 'r') as fp:
-            result.write(fp.read())
-
-        shutil.rmtree(working_dir, ignore_errors=True)
-
-        if out is None:
-            return result
-
-
-MIMETemplateLoader.add_factory('pdf', Template)

Reply via email to