|
|
|
@ -94,9 +94,9 @@ def post_unlock_packages(f):
|
|
|
|
|
|
|
|
|
|
def try_decode_utf8(_bytes):
|
|
|
|
|
try:
|
|
|
|
|
return _bytes.decode("UTF-8")
|
|
|
|
|
return _bytes.decode("UTF-8"), True
|
|
|
|
|
except UnicodeDecodeError as e:
|
|
|
|
|
return _bytes
|
|
|
|
|
return _bytes, False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DataVarsConfig(SimpleDataVars):
|
|
|
|
@ -1631,7 +1631,7 @@ class _file(_error):
|
|
|
|
|
typeFormat not in HParams.Formats.Executable):
|
|
|
|
|
self.F_CONF = self.__openConfFile(self.nameFileConfig)
|
|
|
|
|
if self.F_TEMPL and self.F_CONF:
|
|
|
|
|
self.textTemplate = try_decode_utf8(self.F_TEMPL.read())
|
|
|
|
|
self.textTemplate, ___ = try_decode_utf8(self.F_TEMPL.read())
|
|
|
|
|
self.closeTemplFile()
|
|
|
|
|
if self.configMode == T_NEWCFG:
|
|
|
|
|
origConfigName = re.sub(r'/._cfg\d{4}_([^/]+)$', '/\\1',
|
|
|
|
@ -1643,7 +1643,7 @@ class _file(_error):
|
|
|
|
|
else:
|
|
|
|
|
self.textConfig = newBuffer
|
|
|
|
|
else:
|
|
|
|
|
self.textConfig = try_decode_utf8(self.F_CONF.read())
|
|
|
|
|
self.textConfig, ___ = try_decode_utf8(self.F_CONF.read())
|
|
|
|
|
|
|
|
|
|
def copy_mod_own(self, source, target):
|
|
|
|
|
try:
|
|
|
|
@ -5497,7 +5497,7 @@ gettext -d cl_template "$*"
|
|
|
|
|
self.setError(_("Failed to open the template") + _(": ") +
|
|
|
|
|
self.nameFileTemplate)
|
|
|
|
|
return [], False
|
|
|
|
|
self.textTemplate = try_decode_utf8(self.F_TEMPL.read())
|
|
|
|
|
self.textTemplate, ___ = try_decode_utf8(self.F_TEMPL.read())
|
|
|
|
|
self.closeTemplFile()
|
|
|
|
|
objHeadNew = fileHeader(nameFileTemplate, self.textTemplate, False,
|
|
|
|
|
templateFileType, objVar=self.objVar,
|
|
|
|
@ -5724,7 +5724,7 @@ gettext -d cl_template "$*"
|
|
|
|
|
F_CONF = self.openTemplFile(templateFile)
|
|
|
|
|
if not F_CONF:
|
|
|
|
|
raise IOError
|
|
|
|
|
buff = try_decode_utf8(F_CONF.read())
|
|
|
|
|
buff, ___ = try_decode_utf8(F_CONF.read())
|
|
|
|
|
F_CONF.close()
|
|
|
|
|
fMode, fUid, fGid = getModeFile(templateFile)
|
|
|
|
|
except (OSError, IOError):
|
|
|
|
@ -6023,7 +6023,7 @@ gettext -d cl_template "$*"
|
|
|
|
|
# Выполняем условия для блока текста а так-же заменяем переменные
|
|
|
|
|
self.nameFileTemplate = os.path.abspath(nameFileTemplate)
|
|
|
|
|
self.F_TEMPL = self.openTemplFile(self.nameFileTemplate)
|
|
|
|
|
origTextTemplate = try_decode_utf8(self.F_TEMPL.read())
|
|
|
|
|
origTextTemplate, file_is_unicode = try_decode_utf8(self.F_TEMPL.read())
|
|
|
|
|
self.textTemplate = origTextTemplate
|
|
|
|
|
self.configMode = T_ORIGIN
|
|
|
|
|
self.closeTemplFile()
|
|
|
|
@ -6034,11 +6034,12 @@ gettext -d cl_template "$*"
|
|
|
|
|
templateFileType = "text"
|
|
|
|
|
else:
|
|
|
|
|
templateFileType = self.getTemplateType()
|
|
|
|
|
if templateFileType == "bin" and isinstance(self.textTemplate, str):
|
|
|
|
|
#probably svg file
|
|
|
|
|
self.textTemplate = self.textTemplate.encode("UTF-8")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if templateFileType == "text" and not file_is_unicode:
|
|
|
|
|
#go home getTemplateType, you're drunk
|
|
|
|
|
templateFileType = "bin"
|
|
|
|
|
elif templateFileType == "bin" and file_is_unicode:
|
|
|
|
|
#probably svg file
|
|
|
|
|
self.textTemplate = self.textTemplate.encode("UTF-8")
|
|
|
|
|
headerLine = self.getHeaderText(self.textTemplate, binary = templateFileType == "bin")
|
|
|
|
|
if headerLine:
|
|
|
|
|
envparam = "%s=" % HParams.Environ
|
|
|
|
|