diff --git a/pym/cl_datavars.py b/pym/cl_datavars.py index eee5e27..346b502 100644 --- a/pym/cl_datavars.py +++ b/pym/cl_datavars.py @@ -175,7 +175,7 @@ class DataVars(object): dataVar = getattr(moduleVar.Data, nameVar) except AttributeError, e: pass - if dataVar: + if not dataVar is False: break if dataVar == False: err1 = _("Not found variable %s")%nameVar diff --git a/pym/cl_template.py b/pym/cl_template.py index c2c1c1f..df4dfb9 100644 --- a/pym/cl_template.py +++ b/pym/cl_template.py @@ -46,7 +46,7 @@ class _shareTermsFunction: _reFunctionArgvInSquareBrackets = "a-zA-Z0-9_\-\+\,\*\/\.\'\"~\\\\ " _reFunctionArgvText = "[%s]"%_reFunctionArgvInSquareBrackets # регулярное выражение для поиска функции в шаблоне - _reFunctionText = "([a-zA-Z0-9\_\-]+)\(%s+\)" %_reFunctionArgvText + _reFunctionText = "([a-zA-Z0-9\_\-]+)\((%s+|)\)" %_reFunctionArgvText class _terms(_error, _shareTermsFunction): @@ -2922,6 +2922,34 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction): textTemplateTmp[resS.end():] 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): """Печать ошибки при обработке функций шаблона""" print _("error in template %s")%self.nameTemplate @@ -3035,7 +3063,7 @@ class template(_file, _terms, xmlShare, templateFormat, _shareTemplate): self.varEnd),re.M) # Условия self._reTermBloc = re.compile("#\?(?P[a-zA-Z0-9\-_]+)\ -(?P\(%s+\))?\ +(?P\((%s+|)\))?\ (?P[\>\<\=\!\&\|]+\ [\>\<\=\!\|\&\(\)%s]*)#\ \n*(?P.+?)\n*#(?P=rTerm)#(?P[ ,\t]*\n?)"\ @@ -4589,4 +4617,4 @@ class iniParser(_error, templateFormat): nSect = objIni.docObj.getNameArea(xmlNode) if nSect: namesSection.append(nSect) - return namesSection \ No newline at end of file + return namesSection diff --git a/pym/cl_vars.py b/pym/cl_vars.py index c408567..cff41bc 100644 --- a/pym/cl_vars.py +++ b/pym/cl_vars.py @@ -140,6 +140,10 @@ class Data: # install / uninstall - установка и удаление программы cl_pass_action = {} + # Состояние программы + # Указываем дополнительно к cl_pass_action в случае необходимости + cl_pass_state = {} + # Jabber ID пользователя ur_jid = {'mode':"r", 'official':True} @@ -150,4 +154,10 @@ class Data: # ip или имя домена (под управлением calculate-server) cl_remote_host = {'mode':'r', 'official':True} - + # Переменная работающая совместно с функцией шаблонов belong(имя_пакета) + # Если переменная будет определена то будут использованы шаблоны + # у которых параметр имя пакета функции шаблонов belong(имя_пакета) + # совпадает с значением этой переменной + # (имя_пакета == значение cl_belong_pkg) + cl_belong_pkg = {'mode':'r', 'official':True} +