|
|
@ -46,7 +46,7 @@ class _shareTermsFunction:
|
|
|
|
_reFunctionArgvInSquareBrackets = "a-zA-Z0-9_\-\+\,\*\/\.\'\"~\\\\ "
|
|
|
|
_reFunctionArgvInSquareBrackets = "a-zA-Z0-9_\-\+\,\*\/\.\'\"~\\\\ "
|
|
|
|
_reFunctionArgvText = "[%s]"%_reFunctionArgvInSquareBrackets
|
|
|
|
_reFunctionArgvText = "[%s]"%_reFunctionArgvInSquareBrackets
|
|
|
|
# регулярное выражение для поиска функции в шаблоне
|
|
|
|
# регулярное выражение для поиска функции в шаблоне
|
|
|
|
_reFunctionText = "([a-zA-Z0-9\_\-]+)\(%s+\)" %_reFunctionArgvText
|
|
|
|
_reFunctionText = "([a-zA-Z0-9\_\-]+)\((%s+|)\)" %_reFunctionArgvText
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class _terms(_error, _shareTermsFunction):
|
|
|
|
class _terms(_error, _shareTermsFunction):
|
|
|
@ -2922,6 +2922,34 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
textTemplateTmp[resS.end():]
|
|
|
|
textTemplateTmp[resS.end():]
|
|
|
|
return textTemplateTmp
|
|
|
|
return textTemplateTmp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def funcBelong(self, funArgv, resS, localVars, textTemplateTmp):
|
|
|
|
|
|
|
|
"""Функция шаблона belongs().
|
|
|
|
|
|
|
|
В случае установки переменной os_belongs_pkg=имя пакета, и совпадения
|
|
|
|
|
|
|
|
имени пакета в переменной и имени пакета в функции выдает "1" иначе ""
|
|
|
|
|
|
|
|
Если переменная os_belongs_pkg пуста выдает "1"
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
terms = funArgv.replace(" ","").split(",")
|
|
|
|
|
|
|
|
if len(terms) != 1:
|
|
|
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
|
|
|
funcPkg = terms[0]
|
|
|
|
|
|
|
|
if not funcPkg:
|
|
|
|
|
|
|
|
funcPkg = os.path.split(os.path.dirname(self.nameTemplate))[1]
|
|
|
|
|
|
|
|
if not funcPkg:
|
|
|
|
|
|
|
|
print _("incorrect template path")
|
|
|
|
|
|
|
|
self.printErrTemplate()
|
|
|
|
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
|
|
|
pkg = self.objVar.Get("cl_belong_pkg")
|
|
|
|
|
|
|
|
replace = ""
|
|
|
|
|
|
|
|
if pkg:
|
|
|
|
|
|
|
|
if pkg == funcPkg:
|
|
|
|
|
|
|
|
replace = "1"
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
replace = "1"
|
|
|
|
|
|
|
|
textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\
|
|
|
|
|
|
|
|
textTemplateTmp[resS.end():]
|
|
|
|
|
|
|
|
return textTemplateTmp
|
|
|
|
|
|
|
|
|
|
|
|
def printErrTemplate(self):
|
|
|
|
def printErrTemplate(self):
|
|
|
|
"""Печать ошибки при обработке функций шаблона"""
|
|
|
|
"""Печать ошибки при обработке функций шаблона"""
|
|
|
|
print _("error in template %s")%self.nameTemplate
|
|
|
|
print _("error in template %s")%self.nameTemplate
|
|
|
@ -3035,7 +3063,7 @@ class template(_file, _terms, xmlShare, templateFormat, _shareTemplate):
|
|
|
|
self.varEnd),re.M)
|
|
|
|
self.varEnd),re.M)
|
|
|
|
# Условия
|
|
|
|
# Условия
|
|
|
|
self._reTermBloc = re.compile("#\?(?P<rTerm>[a-zA-Z0-9\-_]+)\
|
|
|
|
self._reTermBloc = re.compile("#\?(?P<rTerm>[a-zA-Z0-9\-_]+)\
|
|
|
|
(?P<func>\(%s+\))?\
|
|
|
|
(?P<func>\((%s+|)\))?\
|
|
|
|
(?P<lTerm>[\>\<\=\!\&\|]+\
|
|
|
|
(?P<lTerm>[\>\<\=\!\&\|]+\
|
|
|
|
[\>\<\=\!\|\&\(\)%s]*)#\
|
|
|
|
[\>\<\=\!\|\&\(\)%s]*)#\
|
|
|
|
\n*(?P<body>.+?)\n*#(?P=rTerm)#(?P<end>[ ,\t]*\n?)"\
|
|
|
|
\n*(?P<body>.+?)\n*#(?P=rTerm)#(?P<end>[ ,\t]*\n?)"\
|
|
|
|