[elbe-devel] [PATCH 2/9] elbepack: templates: open preseed template through importlib
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Fri Jun 21 14:22:45 CEST 2024
Instead of retrieving a Path from importlib and expecting etree() to
open it, directly retrieve an open fileobject.
This avoids unpacking the file in certain cases and also avoids the
following warning:
DeprecationWarning: pathlib.Path.__enter__() is deprecated and scheduled for removal in Python 3.13; Path objects as a context manager is a no-op
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/templates.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/elbepack/templates.py b/elbepack/templates.py
index 1cb44ed1cf79..9edcf6c0e8cb 100644
--- a/elbepack/templates.py
+++ b/elbepack/templates.py
@@ -42,7 +42,7 @@ def write_pack_template(outname, fname, d, linebreak=False):
def _default_preseed():
- with importlib.resources.files(elbepack) / 'default-preseed.xml' as f:
+ with importlib.resources.files(elbepack).joinpath('default-preseed.xml').open('rb') as f:
return etree(f)
--
2.45.2
More information about the elbe-devel
mailing list