diff --git a/pym/calculate/lib/cl_template.py b/pym/calculate/lib/cl_template.py index 6e37017..6cb71f7 100644 --- a/pym/calculate/lib/cl_template.py +++ b/pym/calculate/lib/cl_template.py @@ -2948,6 +2948,7 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction): """ fname, op, regpattern = funArgv.replace(" ","").partition(",") regpattern = regpattern.replace("(?\<","(?<") + regpattern = self._replace_hex(regpattern) if not fname or not regpattern: self.raiseErrTemplate() try: @@ -3413,6 +3414,13 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction): textTemplateTmp[resS.end():] return (textTemplateTmp) + def _replace_hex(self, text): + """ + Заменить в строке комбинацию \\x00 на символ + """ + return re.sub(r'\\x([0-9a-fA-F]{2})', + lambda x:chr(int(x.group(1),16)), text) + def funcReplace(self, funArgv, resS, localVars, textTemplateTmp, nameTemp): """локальная функция заменяет в значении переменной old на new @@ -3437,8 +3445,7 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction): textArgv = term[1:-1] for replTerm in replTerms: textArgv = textArgv.replace(*replTerm) - textArgv = re.sub(r'\\x([0-9a-fA-F]{2})', - lambda x:chr(int(x.group(1),16)),textArgv) + textArgv = self._replace_hex(textArgv) listArgv.append(textArgv) elif term.startswith("'") and term.endswith("'"): listArgv.append(term[1:-1])