[elbe-devel] [PATCH 01/19] elbepack: simplify implementation of function template

Thomas Weißschuh thomas.weissschuh at linutronix.de
Tue Mar 19 08:47:30 CET 2024


Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/templates.py | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/elbepack/templates.py b/elbepack/templates.py
index 45dc2ddf15f5..7b9c5e9a95df 100644
--- a/elbepack/templates.py
+++ b/elbepack/templates.py
@@ -17,13 +17,10 @@ def fix_linebreak_escapes(s):
 
 def template(fname, d, linebreak=False):
     try:
-        if linebreak:
-            return Template(
-                filename=fname,
-                preprocessor=fix_linebreak_escapes).render(
-                **d)
-
-        return Template(filename=fname).render(**d)
+        return Template(
+            filename=fname,
+            preprocessor=fix_linebreak_escapes if linebreak else None,
+        ).render(**d)
     except BaseException:
         print(exceptions.text_error_template().render())
         raise

-- 
2.44.0



More information about the elbe-devel mailing list