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.4 KiB
42 lines
1.4 KiB
4 days ago
|
From ec4ff67267b4b33715754ed9f947c4572c541f0e 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/4] 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 77fb4ff..f2844fc 100644
|
||
|
--- a/src/pylorax/ltmpl.py
|
||
|
+++ b/src/pylorax/ltmpl.py
|
||
|
@@ -414,6 +414,21 @@ class LoraxTemplateRunner(TemplateRunner, InstallpkgMixin):
|
||
|
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.43.5
|
||
|
|