[elbe-devel] [PATCH 05/19] elbepack: drop mako_template_dir

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


Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/directories.py | 2 --
 elbepack/templates.py   | 9 ++++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/elbepack/directories.py b/elbepack/directories.py
index 76d65e328afe..3786cc0416c0 100644
--- a/elbepack/directories.py
+++ b/elbepack/directories.py
@@ -22,8 +22,6 @@ def get_cmdlist():
 
 pack_dir = elbepack.__path__[0]
 
-mako_template_dir = os.path.join(pack_dir, 'makofiles')
-
 default_preseed_fname = os.path.join(pack_dir, 'default-preseed.xml')
 xsdtoasciidoc_mako_fname = os.path.join(pack_dir, 'xsdtoasciidoc.mako')
 
diff --git a/elbepack/templates.py b/elbepack/templates.py
index 6484e672c441..f0018eecc7db 100644
--- a/elbepack/templates.py
+++ b/elbepack/templates.py
@@ -2,9 +2,11 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 # SPDX-FileCopyrightText: 2014-2017 Linutronix GmbH
 
+import importlib.resources
 import os
 
-from elbepack.directories import default_preseed_fname, mako_template_dir
+import elbepack.makofiles
+from elbepack.directories import default_preseed_fname
 from elbepack.treeutils import etree
 
 from mako import exceptions
@@ -33,9 +35,10 @@ def write_template(outname, fname, d, linebreak=False):
 
 
 def write_pack_template(outname, fname, d, linebreak=False):
-    template_name = os.path.join(mako_template_dir, fname)
+    template_dir = importlib.resources.files(elbepack.makofiles)
 
-    write_template(outname, template_name, d, linebreak)
+    with importlib.resources.as_file(template_dir / fname) as template:
+        write_template(outname, template, d, linebreak)
 
 
 def get_preseed(xml):

-- 
2.44.0



More information about the elbe-devel mailing list