[elbe-devel] [PATCH 01/10] debianize: use template () from elbepack.templates

Torben Hohn torben.hohn at linutronix.de
Wed Mar 22 17:44:08 CET 2017


Reuse function from elbepack.templates, which has better
error reporting.

We also have write_template, and write_pack_template in that
module. These should be used.
---
 elbepack/debianize/base.py   | 7 ++-----
 elbepack/debianize/kernel.py | 2 +-
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/elbepack/debianize/base.py b/elbepack/debianize/base.py
index 24b1d58..e9c0771 100644
--- a/elbepack/debianize/base.py
+++ b/elbepack/debianize/base.py
@@ -28,10 +28,7 @@ from npyscreen import TitleText, TitleSelectOne, ButtonPress, notify
 
 from shutil import copyfile
 
-from mako.template import Template
-
-def template (deb, fname):
-    return Template(filename=fname).render(**deb)
+from elbepack.templates import template
 
 class DebianizeBase (FormMultiPage):
     def __init__ (self):
@@ -100,7 +97,7 @@ class DebianizeBase (FormMultiPage):
 
         with open ('debian/source/format', 'w') as f:
             mako = os.path.join(self.tmpl_dir, 'format.mako')
-            f.write (template(self.deb, mako))
+            f.write (template(mako, self.deb))
 
         copyfile (os.path.join(self.tmpl_dir, 'copyright'), 'debian/copyright')
         with open ('debian/compat', 'w') as f:
diff --git a/elbepack/debianize/kernel.py b/elbepack/debianize/kernel.py
index 4635861..6030843 100644
--- a/elbepack/debianize/kernel.py
+++ b/elbepack/debianize/kernel.py
@@ -75,7 +75,7 @@ class Kernel (DebianizeBase):
         for tmpl in ['control', 'rules', 'preinst', 'postinst', 'prerm', 'postrm']:
             with open (os.path.join('debian/', tmpl), 'w') as f:
                 mako = os.path.join(self.tmpl_dir, tmpl+'.mako')
-                f.write (template(self.deb, mako))
+                f.write (template(mako, self.deb))
 
         cmd = 'dch --package linux-' + pkg_name + \
                    ' -v ' + self.deb['p_version'] + \
-- 
2.1.4





More information about the elbe-devel mailing list