You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
9 months ago
|
From 432c907e8f5d306611e84cd6fe56087362794f68 Mon Sep 17 00:00:00 2001
|
||
|
From: tigro <tigro@msvsphere-os.ru>
|
||
|
Date: Fri, 22 Dec 2023 13:06:59 +0300
|
||
|
Subject: [PATCH 2/2] Add iconv template command
|
||
|
|
||
|
---
|
||
|
src/pylorax/ltmpl.py | 15 +++++++++++++++
|
||
|
1 file changed, 15 insertions(+)
|
||
|
|
||
|
diff --git a/src/pylorax/ltmpl.py b/src/pylorax/ltmpl.py
|
||
|
index ccd297c..a06534a 100644
|
||
|
--- a/src/pylorax/ltmpl.py
|
||
|
+++ b/src/pylorax/ltmpl.py
|
||
|
@@ -275,6 +275,21 @@ class LoraxTemplateRunner(TemplateRunner):
|
||
|
for pkg in debug_pkgs:
|
||
|
f.write("%s\n" % pkg)
|
||
|
|
||
|
+ def iconv(self, encoding, *fileglobs):
|
||
|
+ '''
|
||
|
+ iconv ENCODING [FILEGLOB ...]
|
||
|
+ Convert given files from UTF-8 to a specified encoding.
|
||
|
+
|
||
|
+ Examples:
|
||
|
+ iconv 'cp866' ${BOOTDIR}/isolinux.cfg
|
||
|
+ '''
|
||
|
+ for g in fileglobs:
|
||
|
+ for f in rglob(self._out(g)):
|
||
|
+ with open(f, "r", encoding="utf-8") as fd:
|
||
|
+ content = fd.read()
|
||
|
+ with open(f, "wb") as fd:
|
||
|
+ fd.write(content.encode(encoding))
|
||
|
+
|
||
|
def install(self, srcglob, dest):
|
||
|
'''
|
||
|
install SRC DEST
|
||
|
--
|
||
|
2.43.0
|
||
|
|