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.
42 lines
1.3 KiB
42 lines
1.3 KiB
From 9b34c5ad852edd1eb68d78363e3be12ac49b44ce Mon Sep 17 00:00:00 2001
|
|
From: Eugene Zamriy <evgeniy.zamriy@softline.com>
|
|
Date: Wed, 26 Jul 2023 22:55:04 +0300
|
|
Subject: [PATCH 3/3] Add iconv template command
|
|
|
|
Adds the "iconv" template command that converts file(s) from UTF-8
|
|
to a specified encoding. This change was required to add Russian
|
|
localization to the BIOS mode bootloader.
|
|
---
|
|
src/pylorax/ltmpl.py | 15 +++++++++++++++
|
|
1 file changed, 15 insertions(+)
|
|
|
|
diff --git a/src/pylorax/ltmpl.py b/src/pylorax/ltmpl.py
|
|
index 36e09e9..7c5b56f 100644
|
|
--- a/src/pylorax/ltmpl.py
|
|
+++ b/src/pylorax/ltmpl.py
|
|
@@ -273,6 +273,21 @@ class LoraxTemplateRunner(TemplateRunner):
|
|
f.write("\n".join(sorted(debug_pkgs)))
|
|
f.write("\n")
|
|
|
|
+ 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.40.1
|
|
|