|
|
@ -197,8 +197,8 @@ class _terms(_error, _shareTermsFunction):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
valVars = self.objVar.Get(vals[0])
|
|
|
|
valVars = self.objVar.Get(vals[0])
|
|
|
|
except self.objVar.DataVarsError, e:
|
|
|
|
except self.objVar.DataVarsError, e:
|
|
|
|
print textError
|
|
|
|
cl_overriding.printERROR(textError)
|
|
|
|
print e
|
|
|
|
cl_overriding.printERROR(e)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
# Номера версий для ini
|
|
|
|
# Номера версий для ini
|
|
|
|
flagNotIniFunct = True
|
|
|
|
flagNotIniFunct = True
|
|
|
@ -1083,12 +1083,10 @@ class xmlDoc:
|
|
|
|
if not nameField:
|
|
|
|
if not nameField:
|
|
|
|
return []
|
|
|
|
return []
|
|
|
|
parentNode = xmlField.parentNode
|
|
|
|
parentNode = xmlField.parentNode
|
|
|
|
#print parentNode.toprettyxml()
|
|
|
|
|
|
|
|
if parentNode:
|
|
|
|
if parentNode:
|
|
|
|
fieldsVal = xpath.Evaluate(\
|
|
|
|
fieldsVal = xpath.Evaluate(\
|
|
|
|
"child::field[attribute::type='seplist'][child::name='%s'] "\
|
|
|
|
"child::field[attribute::type='seplist'][child::name='%s'] "\
|
|
|
|
%(nameField), parentNode)
|
|
|
|
%(nameField), parentNode)
|
|
|
|
#print nameField
|
|
|
|
|
|
|
|
return fieldsVal
|
|
|
|
return fieldsVal
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return []
|
|
|
|
return []
|
|
|
@ -1197,13 +1195,8 @@ class xmlDoc:
|
|
|
|
self.getActionField(node) == "drop"):
|
|
|
|
self.getActionField(node) == "drop"):
|
|
|
|
self.setActionField(node,"insert")
|
|
|
|
self.setActionField(node,"insert")
|
|
|
|
self.joinField(xmlOldArea, node)
|
|
|
|
self.joinField(xmlOldArea, node)
|
|
|
|
#else:
|
|
|
|
|
|
|
|
#self.setActionField(node, "append")
|
|
|
|
|
|
|
|
#baseBody.appendChild(node)
|
|
|
|
|
|
|
|
for node in notSepListField:
|
|
|
|
for node in notSepListField:
|
|
|
|
if self.getTypeField(node) == "seplist":
|
|
|
|
if self.getTypeField(node) == "seplist":
|
|
|
|
#if removeNodesDict.has_key(self.getNameField(node)):
|
|
|
|
|
|
|
|
#print removeNodesDict[self.getNameField(node)]
|
|
|
|
|
|
|
|
self.setActionField(node, "append")
|
|
|
|
self.setActionField(node, "append")
|
|
|
|
xmlOldArea.appendChild(node)
|
|
|
|
xmlOldArea.appendChild(node)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -2197,14 +2190,15 @@ class _shareTemplate:
|
|
|
|
gid = pwdObj.pw_gid
|
|
|
|
gid = pwdObj.pw_gid
|
|
|
|
homeDir = pwdObj.pw_dir
|
|
|
|
homeDir = pwdObj.pw_dir
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
print _("Can not found user %s")%str(userName)
|
|
|
|
cl_overriding.printERROR(_("Can not found user %s")%str(userName))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
if groupsInfo:
|
|
|
|
if groupsInfo:
|
|
|
|
import grp
|
|
|
|
import grp
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
groupName = grp.getgrgid(gid).gr_name
|
|
|
|
groupName = grp.getgrgid(gid).gr_name
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
print _("Can not found group id %s")%str(gid)
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
|
|
|
_("Can not found group id %s")%str(gid))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
groupsNames = map(lambda x: x.gr_name,\
|
|
|
|
groupsNames = map(lambda x: x.gr_name,\
|
|
|
|
filter(lambda x: userName in x.gr_mem, grp.getgrall()))
|
|
|
|
filter(lambda x: userName in x.gr_mem, grp.getgrall()))
|
|
|
@ -2253,7 +2247,6 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, objVar):
|
|
|
|
def __init__(self, objVar):
|
|
|
|
# Если не определен словарь функций шаблона
|
|
|
|
# Если не определен словарь функций шаблона
|
|
|
|
#print "dict", templateFunction.__dict__.items()
|
|
|
|
|
|
|
|
if not self.templateFunction:
|
|
|
|
if not self.templateFunction:
|
|
|
|
# префикс функций шаблона
|
|
|
|
# префикс функций шаблона
|
|
|
|
pref = "func"
|
|
|
|
pref = "func"
|
|
|
@ -2326,26 +2319,29 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
num = int(localVars[strNum])
|
|
|
|
num = int(localVars[strNum])
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
print _("error var %s not int")%str(strNum)
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
|
|
|
_("error var %s not int")%str(strNum))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
elif self.objVar.exists(strNum):
|
|
|
|
elif self.objVar.exists(strNum):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
num = int(self.objVar.Get(strNum))
|
|
|
|
num = int(self.objVar.Get(strNum))
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
print _("error var %s not int")%str(strNum)
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
|
|
|
_("error var %s not int")%str(strNum))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
print _("error local var %s not defined")\
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
%str(strNum)
|
|
|
|
_("error local var %s not defined")%str(strNum))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
if minus:
|
|
|
|
if minus:
|
|
|
|
num = -num
|
|
|
|
num = -num
|
|
|
|
strNumers.append(num)
|
|
|
|
strNumers.append(num)
|
|
|
|
return sum(strNumers)
|
|
|
|
return sum(strNumers)
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
print _("error template term %s, incorrect data")%str(term)
|
|
|
|
cl_overriding.printERROR(_("error template term %s, incorrect data")\
|
|
|
|
|
|
|
|
%str(term))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
def multAndDiv(self, term, localVars):
|
|
|
|
def multAndDiv(self, term, localVars):
|
|
|
@ -2432,8 +2428,8 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
if len(terms) == 2:
|
|
|
|
if len(terms) == 2:
|
|
|
|
if not terms[0] in ["ver","num","char","key"]:
|
|
|
|
if not terms[0] in ["ver","num","char","key"]:
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
print _("first argument function is not 'ver' or 'num' or \
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
'char'")
|
|
|
|
_("first argument function is not 'ver' or 'num' or 'char'"))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
if len(terms) == 1:
|
|
|
|
if len(terms) == 1:
|
|
|
|
fileName = terms[0].strip()
|
|
|
|
fileName = terms[0].strip()
|
|
|
@ -2554,13 +2550,15 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
fArgvNames = ['num','pas']
|
|
|
|
fArgvNames = ['num','pas']
|
|
|
|
if not terms[0] in fArgvNames:
|
|
|
|
if not terms[0] in fArgvNames:
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
print _("first argument function is not 'num' or 'pas'")
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
|
|
|
_("first argument function is not 'num' or 'pas'"))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
lenStr = int(terms[1])
|
|
|
|
lenStr = int(terms[1])
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
print _("two argument function is not number")
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
|
|
|
_("two argument function is not number"))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
if terms[0] == fArgvNames[0]:
|
|
|
|
if terms[0] == fArgvNames[0]:
|
|
|
|
replace=''.join([random.choice(string.digits)\
|
|
|
|
replace=''.join([random.choice(string.digits)\
|
|
|
@ -2593,14 +2591,15 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
fArgvNames = ['upper','lower','capitalize']
|
|
|
|
fArgvNames = ['upper','lower','capitalize']
|
|
|
|
if not terms[0] in fArgvNames:
|
|
|
|
if not terms[0] in fArgvNames:
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
print _("first argument function is not 'upper' or 'lower' or\
|
|
|
|
cl_overriding.printERROR(_("first argument function is not 'upper' \
|
|
|
|
'capitalize'")
|
|
|
|
or 'lower' or 'capitalize'"))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
strValue = str(self.objVar.Get(terms[1]))
|
|
|
|
strValue = str(self.objVar.Get(terms[1]))
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
print _("error in template %s")%self.nameTemplate
|
|
|
|
cl_overriding.printERROR(_("error in template %s")\
|
|
|
|
print _("error var %s not found")%str(terms[1])
|
|
|
|
%self.nameTemplate)
|
|
|
|
|
|
|
|
cl_overriding.printERROR(_("error var %s not found")%str(terms[1]))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
replace = ""
|
|
|
|
replace = ""
|
|
|
|
strValue = _toUNICODE(strValue)
|
|
|
|
strValue = _toUNICODE(strValue)
|
|
|
@ -2640,13 +2639,15 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
self.stackGlobalVars.append(str(value))
|
|
|
|
self.stackGlobalVars.append(str(value))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
print _("error var %s exists")%str(nameLocVar)
|
|
|
|
cl_overriding.printERROR(_("error var %s exists")\
|
|
|
|
|
|
|
|
%str(nameLocVar))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
# Если переменная не существует
|
|
|
|
# Если переменная не существует
|
|
|
|
if len(terms) == 1:
|
|
|
|
if len(terms) == 1:
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
print _("error var %s not exists")%str(nameLocVar)
|
|
|
|
cl_overriding.printERROR(_("error var %s not exists")\
|
|
|
|
|
|
|
|
%str(nameLocVar))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
elif len(terms) == 2:
|
|
|
|
elif len(terms) == 2:
|
|
|
|
value = terms[1].strip()
|
|
|
|
value = terms[1].strip()
|
|
|
@ -2674,7 +2675,8 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
localVars[nameLocVar] = self.stackGlobalVars.pop()
|
|
|
|
localVars[nameLocVar] = self.stackGlobalVars.pop()
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
print _("error, gloval variables stack is empty")
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
|
|
|
|
_("error, gloval variables stack is empty"))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
@ -2824,7 +2826,8 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
value = str(self.objVar.Get(nameVar))
|
|
|
|
value = str(self.objVar.Get(nameVar))
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
print _("not found template variable '%s'")%str(nameVar)
|
|
|
|
cl_overriding.printERROR(_("not found template variable '%s'")\
|
|
|
|
|
|
|
|
%str(nameVar))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
replace = value.replace(old,new)
|
|
|
|
replace = value.replace(old,new)
|
|
|
|
textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\
|
|
|
|
textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\
|
|
|
@ -2849,7 +2852,7 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
errMsg = self.getError()
|
|
|
|
errMsg = self.getError()
|
|
|
|
if errMsg:
|
|
|
|
if errMsg:
|
|
|
|
print errMsg
|
|
|
|
cl_overriding.printERROR(errMsg)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
self.valuesVarEnv[nameVar] = value
|
|
|
|
self.valuesVarEnv[nameVar] = value
|
|
|
|
replace = value
|
|
|
|
replace = value
|
|
|
@ -2938,7 +2941,7 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
if not funcPkg:
|
|
|
|
if not funcPkg:
|
|
|
|
funcPkg = os.path.split(os.path.dirname(self.nameTemplate))[1]
|
|
|
|
funcPkg = os.path.split(os.path.dirname(self.nameTemplate))[1]
|
|
|
|
if not funcPkg:
|
|
|
|
if not funcPkg:
|
|
|
|
print _("incorrect template path")
|
|
|
|
cl_overriding.printERROR(_("incorrect template path"))
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
pkg = self.objVar.Get("cl_belong_pkg")
|
|
|
|
pkg = self.objVar.Get("cl_belong_pkg")
|
|
|
@ -2954,8 +2957,9 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
|
|
|
|
|
|
|
|
def printErrTemplate(self):
|
|
|
|
def printErrTemplate(self):
|
|
|
|
"""Печать ошибки при обработке функций шаблона"""
|
|
|
|
"""Печать ошибки при обработке функций шаблона"""
|
|
|
|
print _("error in template %s")%self.nameTemplate
|
|
|
|
cl_overriding.printERROR(_("error in template %s")%self.nameTemplate)
|
|
|
|
print _("error template term '%s'")%str(self.functText)
|
|
|
|
cl_overriding.printERROR(_("error template term '%s'")\
|
|
|
|
|
|
|
|
%str(self.functText))
|
|
|
|
|
|
|
|
|
|
|
|
def applyFuncTemplate(self, textTemplate, nameTemplate, nameSystemFile):
|
|
|
|
def applyFuncTemplate(self, textTemplate, nameTemplate, nameSystemFile):
|
|
|
|
"""Применяет функции к тексту шаблона"""
|
|
|
|
"""Применяет функции к тексту шаблона"""
|
|
|
@ -2984,8 +2988,9 @@ class templateFunction(_error, _shareTemplate, _shareTermsFunction):
|
|
|
|
flagIniFunc = True
|
|
|
|
flagIniFunc = True
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.printErrTemplate()
|
|
|
|
self.printErrTemplate()
|
|
|
|
print _("can not found template function '%s'")\
|
|
|
|
cl_overriding.printERROR(\
|
|
|
|
%str(self.functText)
|
|
|
|
_("can not found template function '%s'")\
|
|
|
|
|
|
|
|
%str(self.functText))
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
if flagIniFunc:
|
|
|
|
if flagIniFunc:
|
|
|
@ -3197,8 +3202,8 @@ re.M|re.S)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
varValue = str(self.objVar.Get(varName))
|
|
|
|
varValue = str(self.objVar.Get(varName))
|
|
|
|
except self.objVar.DataVarsError, e:
|
|
|
|
except self.objVar.DataVarsError, e:
|
|
|
|
print _("error in template %s")%nameTemplate
|
|
|
|
cl_overriding.printERROR(_("error in template %s")%nameTemplate)
|
|
|
|
print e
|
|
|
|
cl_overriding.printERROR(e)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
cl_overriding.exit(1)
|
|
|
|
textTemplateTmp = textTemplateTmp.replace(mark, varValue)
|
|
|
|
textTemplateTmp = textTemplateTmp.replace(mark, varValue)
|
|
|
|
resS = self._reVar.search(textTemplateTmp)
|
|
|
|
resS = self._reVar.search(textTemplateTmp)
|
|
|
@ -4080,7 +4085,6 @@ re.M|re.S)
|
|
|
|
self.textTemplate = self.applyTermsTemplate(self.textTemplate,
|
|
|
|
self.textTemplate = self.applyTermsTemplate(self.textTemplate,
|
|
|
|
nameFileTemplate,
|
|
|
|
nameFileTemplate,
|
|
|
|
nameFileConfig)
|
|
|
|
nameFileConfig)
|
|
|
|
#print "|%s|" %(self.textTemplate)
|
|
|
|
|
|
|
|
# Заменяем переменные на их значения
|
|
|
|
# Заменяем переменные на их значения
|
|
|
|
self.textTemplate = self.applyVarsTemplate(self.textTemplate,
|
|
|
|
self.textTemplate = self.applyVarsTemplate(self.textTemplate,
|
|
|
|
nameFileTemplate)
|
|
|
|
nameFileTemplate)
|
|
|
@ -4210,7 +4214,6 @@ re.M|re.S)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.textConfig = title + tmpTemplate
|
|
|
|
self.textConfig = title + tmpTemplate
|
|
|
|
|
|
|
|
|
|
|
|
#print self.textConfig
|
|
|
|
|
|
|
|
self.saveConfFile()
|
|
|
|
self.saveConfFile()
|
|
|
|
return filesApply
|
|
|
|
return filesApply
|
|
|
|
# Cзади
|
|
|
|
# Cзади
|
|
|
@ -4297,11 +4300,7 @@ re.M|re.S)
|
|
|
|
nameRootNode=nameFileConfig.rpartition("/")[2].split(".")[0]
|
|
|
|
nameRootNode=nameFileConfig.rpartition("/")[2].split(".")[0]
|
|
|
|
objTemplOld.setNameBodyNode(nameRootNode)
|
|
|
|
objTemplOld.setNameBodyNode(nameRootNode)
|
|
|
|
|
|
|
|
|
|
|
|
#print "#%s#" %(objTemplOld.docObj.body.toprettyxml())
|
|
|
|
|
|
|
|
#print "#%s#" %(objTemplNew.docObj.body.toprettyxml())
|
|
|
|
|
|
|
|
objTemplOld.join(objTemplNew)
|
|
|
|
objTemplOld.join(objTemplNew)
|
|
|
|
#print objTemplOld.doc.toprettyxml()
|
|
|
|
|
|
|
|
#print objTemplNew.doc.toprettyxml()
|
|
|
|
|
|
|
|
if "xml_" in formatTemplate:
|
|
|
|
if "xml_" in formatTemplate:
|
|
|
|
if objTemplOld.getError():
|
|
|
|
if objTemplOld.getError():
|
|
|
|
self.setError(_("False template") + ": " +\
|
|
|
|
self.setError(_("False template") + ": " +\
|
|
|
|