From 0b43a41eb8db73314a5502bcfce54691c74c2003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B0=D0=BC=D0=BE=D1=83=D0=BA=D0=B8=D0=BD=20=D0=90?= =?UTF-8?q?=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Fri, 4 Jun 2010 14:52:50 +0400 Subject: [PATCH] Modified server() template function --- pym/cl_template.py | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/pym/cl_template.py b/pym/cl_template.py index 1341e74..4ff042f 100644 --- a/pym/cl_template.py +++ b/pym/cl_template.py @@ -2789,30 +2789,6 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction): textTemplateTmp[resS.end():] return (textTemplateTmp) - def funcPop(self, funArgv, resS, localVars, textTemplateTmp): - """локальная функция получает значение - - из стека глобальных переменных и присваивает локальной переменной - - """ - terms = funArgv.replace(" ","").split(",") - # Название локальной переменной - nameLocVar = terms[0] - if len(terms) == 1: - if self.stackGlobalVars: - localVars[nameLocVar] = self.stackGlobalVars.pop() - else: - self.printErrTemplate() - print _("error, gloval variables stack is empty") - cl_overriding.exit(1) - else: - self.printErrTemplate() - cl_overriding.exit(1) - replace = "" - textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\ - textTemplateTmp[resS.end():] - return textTemplateTmp - def funcReplace(self, funArgv, resS, localVars, textTemplateTmp): """локальная функция заменяет в значении переменной old на new @@ -2899,9 +2875,15 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction): из /var/calculate/remote/calculate.env """ terms = funArgv.replace(" ","").split(",") - if len(terms) != 1: + if len(terms)==0 or len(terms)>2: self.printErrTemplate() cl_overriding.exit(1) + nameLocalVar = "" + if len(terms)==2: + if not terms[1]: + self.printErrTemplate() + cl_overriding.exit(1) + nameLocalVar = terms[1] textLine = terms[0] vals = textLine.split(".") if len(vals)!= 2: @@ -2929,7 +2911,11 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction): self.optionsInfo = optInfo replace = '' if service in self.optionsInfo and option in self.optionsInfo[service]: - replace = self.optionsInfo[service][option] + value = self.optionsInfo[service][option] + if nameLocalVar: + localVars[nameLocalVar] = value + else: + replace = value textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\ textTemplateTmp[resS.end():] return textTemplateTmp