|
|
|
@ -114,50 +114,51 @@ class _terms(_error):
|
|
|
|
|
else:
|
|
|
|
|
listEqual.append(k)
|
|
|
|
|
else:
|
|
|
|
|
if self.objVar.defined(vals[0]):
|
|
|
|
|
try:
|
|
|
|
|
valVars = self.objVar.Get(vals[0])
|
|
|
|
|
#print valVars
|
|
|
|
|
#if not valVars:
|
|
|
|
|
#self.setError (_("empty var: ")+\
|
|
|
|
|
#vals[0])
|
|
|
|
|
#return False
|
|
|
|
|
# Cравниваем номера версий
|
|
|
|
|
if "_ver" in vals[0]:
|
|
|
|
|
verFile, verVar = self._convertVers(vals[1],valVars)
|
|
|
|
|
exec("res=("+"'"+verVar+"'"+sepF+"'"+verFile+"'"+")")
|
|
|
|
|
except self.objVar.DataVarsError, e:
|
|
|
|
|
print textError
|
|
|
|
|
print e
|
|
|
|
|
exit(1)
|
|
|
|
|
# Cравниваем номера версий
|
|
|
|
|
if "_ver" in vals[0]:
|
|
|
|
|
verFile, verVar = self._convertVers(vals[1],valVars)
|
|
|
|
|
exec("res=("+"'"+verVar+"'"+sepF+"'"+verFile+"'"+")")
|
|
|
|
|
if res:
|
|
|
|
|
listEqual.append("1")
|
|
|
|
|
else:
|
|
|
|
|
listEqual.append("0")
|
|
|
|
|
else:
|
|
|
|
|
flagTxtTypeVar = True
|
|
|
|
|
try:
|
|
|
|
|
valVars = int(valVars)
|
|
|
|
|
except:
|
|
|
|
|
flagTxtTypeVar = False
|
|
|
|
|
if flagTxtTypeVar:
|
|
|
|
|
try:
|
|
|
|
|
valFile = int(vals[1])
|
|
|
|
|
except:
|
|
|
|
|
self.setError (textError)
|
|
|
|
|
return False
|
|
|
|
|
valVar = valVars
|
|
|
|
|
exec("res=(%d%s%d)"%(valVar,sepF,valFile))
|
|
|
|
|
if res:
|
|
|
|
|
listEqual.append("1")
|
|
|
|
|
else:
|
|
|
|
|
listEqual.append("0")
|
|
|
|
|
else:
|
|
|
|
|
if "int" in str(type(valVars)):
|
|
|
|
|
try:
|
|
|
|
|
valFile = int(vals[1])
|
|
|
|
|
except:
|
|
|
|
|
self.setError (textError)
|
|
|
|
|
return False
|
|
|
|
|
if sepF == "!=" or sepF == "==":
|
|
|
|
|
valFile = vals[1]
|
|
|
|
|
valVar = valVars
|
|
|
|
|
exec("res=(%d%s%d)"%(valVar,sepF,valFile))
|
|
|
|
|
exec("res=("+"'"+valVar+"'"+sepF+"'"+valFile+\
|
|
|
|
|
"'"+")")
|
|
|
|
|
if res:
|
|
|
|
|
listEqual.append("1")
|
|
|
|
|
else:
|
|
|
|
|
listEqual.append("0")
|
|
|
|
|
else:
|
|
|
|
|
if sepF == "!=" or sepF == "==":
|
|
|
|
|
valFile = vals[1]
|
|
|
|
|
valVar = valVars
|
|
|
|
|
exec("res=("+"'"+valVar+"'"+sepF+"'"+valFile+\
|
|
|
|
|
"'"+")")
|
|
|
|
|
if res:
|
|
|
|
|
listEqual.append("1")
|
|
|
|
|
else:
|
|
|
|
|
listEqual.append("0")
|
|
|
|
|
else:
|
|
|
|
|
self.setError (textError)
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
self.setError (_("not defined Var: ") + vals[0])
|
|
|
|
|
return False
|
|
|
|
|
self.setError (textError)
|
|
|
|
|
return False
|
|
|
|
|
exec("res=(%s)"%("".join(listEqual)))
|
|
|
|
|
return res
|
|
|
|
|
|
|
|
|
@ -253,9 +254,9 @@ class calcHeader(_terms):
|
|
|
|
|
elif len(par) == 2:
|
|
|
|
|
self.params[par[0]] = par[1]
|
|
|
|
|
|
|
|
|
|
self.fileType = self._getType()
|
|
|
|
|
self.typeAppend = self._getAppend()
|
|
|
|
|
self.comment = self._getComment()
|
|
|
|
|
self.fileType = self._getType()
|
|
|
|
|
self.typeAppend = self._getAppend()
|
|
|
|
|
reExecRes = self.reExecStr.search(self.body)
|
|
|
|
|
if reExecRes:
|
|
|
|
|
self.execStr = self.body[reExecRes.start():reExecRes.end()]
|
|
|
|
@ -1889,7 +1890,7 @@ class profile(_file, _terms):
|
|
|
|
|
self.setError (_("Empty oct value"))
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def applyVarsProfile(self, textProfile):
|
|
|
|
|
def applyVarsProfile(self, textProfile, nameProfile):
|
|
|
|
|
""" Заменяет переменные на их значения
|
|
|
|
|
"""
|
|
|
|
|
resS = self._reVar.search(textProfile)
|
|
|
|
@ -1898,13 +1899,17 @@ class profile(_file, _terms):
|
|
|
|
|
mark = textProfileTmp[resS.start():resS.end()]
|
|
|
|
|
varName = mark[self._deltVarStart:-self._deltVarEnd]
|
|
|
|
|
varValue = ""
|
|
|
|
|
if self.objVar.defined(varName):
|
|
|
|
|
varValue = str(self.objVar.Get(varName))
|
|
|
|
|
try:
|
|
|
|
|
varValue = str(self.objVar.Get(varName))
|
|
|
|
|
except self.objVar.DataVarsError, e:
|
|
|
|
|
print _("error in profile %s")%nameProfile
|
|
|
|
|
print e
|
|
|
|
|
exit(1)
|
|
|
|
|
textProfileTmp = textProfileTmp.replace(mark, varValue)
|
|
|
|
|
resS = self._reVar.search(textProfileTmp)
|
|
|
|
|
return textProfileTmp
|
|
|
|
|
|
|
|
|
|
def applyFuncProfile(self, textProfile):
|
|
|
|
|
def applyFuncProfile(self, textProfile, nameProfile):
|
|
|
|
|
""" Применяет функции к тексту профиля
|
|
|
|
|
"""
|
|
|
|
|
def equalTerm(term, sNum, localVars):
|
|
|
|
@ -1923,20 +1928,23 @@ class profile(_file, _terms):
|
|
|
|
|
try:
|
|
|
|
|
num = int(self.objVar.Get(strNum))
|
|
|
|
|
except:
|
|
|
|
|
print _("error in profile %s")%nameProfile
|
|
|
|
|
print _("error var %s not int")%str(strNum)
|
|
|
|
|
exit(1)
|
|
|
|
|
else:
|
|
|
|
|
print _("error in profile %s")%nameProfile
|
|
|
|
|
print _("error local var %s not defined")\
|
|
|
|
|
%str(strNum)
|
|
|
|
|
exit(1)
|
|
|
|
|
strNumers.append(num)
|
|
|
|
|
return sum(strNumers)
|
|
|
|
|
print _("error in profile %s")%nameProfile
|
|
|
|
|
print _("error profile term %s, incorrect data")%str(term)
|
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
|
|
def funcSum(resS,localVars,textProfileTmp):
|
|
|
|
|
def funcSum(funTxt,resS,localVars,textProfileTmp):
|
|
|
|
|
"""локальная функция вычисляет первую функцию sum() в профиле"""
|
|
|
|
|
terms = varName[4:-1].split(",")
|
|
|
|
|
terms = funTxt[4:-1].split(",")
|
|
|
|
|
# Название локальной переменной
|
|
|
|
|
nameLocVar = terms[0].strip()
|
|
|
|
|
if not localVars.has_key(nameLocVar):
|
|
|
|
@ -1962,7 +1970,8 @@ class profile(_file, _terms):
|
|
|
|
|
textProfileTmp = textProfileTmp[:resS.start()] + replace +\
|
|
|
|
|
textProfileTmp[resS.end():]
|
|
|
|
|
else:
|
|
|
|
|
print _("error profile term %s")%str(varName)
|
|
|
|
|
print _("error in profile %s")%nameProfile
|
|
|
|
|
print _("error profile term %s")%str(funTxt)
|
|
|
|
|
exit(1)
|
|
|
|
|
return textProfileTmp
|
|
|
|
|
|
|
|
|
@ -1973,9 +1982,9 @@ class profile(_file, _terms):
|
|
|
|
|
textProfileTmp = textProfile
|
|
|
|
|
while resS:
|
|
|
|
|
mark = textProfileTmp[resS.start():resS.end()]
|
|
|
|
|
varName = mark[self._deltVarStart:-self._deltVarEnd]
|
|
|
|
|
if varName[:4] == "sum(":
|
|
|
|
|
textProfileTmp = funcSum(resS, localVars, textProfileTmp)
|
|
|
|
|
funTxt = mark[self._deltVarStart:-self._deltVarEnd]
|
|
|
|
|
if funTxt[:4] == "sum(":
|
|
|
|
|
textProfileTmp = funcSum(funTxt,resS,localVars,textProfileTmp)
|
|
|
|
|
resS = self._reFunc.search(textProfileTmp)
|
|
|
|
|
else:
|
|
|
|
|
resS = False
|
|
|
|
@ -2098,10 +2107,10 @@ class profile(_file, _terms):
|
|
|
|
|
self.closeFiles()
|
|
|
|
|
return (createdDirs, filesApply)
|
|
|
|
|
|
|
|
|
|
def __getApplyHeadProfile(self ,newFile, oldFile):
|
|
|
|
|
def __getApplyHeadProfile(self ,newFile, oldFile, copyFile):
|
|
|
|
|
"""Применяет заголовок к профилю (права, владелец, и.т. д)"""
|
|
|
|
|
self.closeFiles()
|
|
|
|
|
if not self.newProfile:
|
|
|
|
|
if copyFile:
|
|
|
|
|
self.nameFileNew = self.absFileName(newFile)
|
|
|
|
|
self.FN = self.openNewFile(self.nameFileNew)
|
|
|
|
|
self.newProfile = self.FN.read()
|
|
|
|
@ -2251,7 +2260,6 @@ class profile(_file, _terms):
|
|
|
|
|
return newCl
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def join(self, newFile, oldFile, ListOptTitle):
|
|
|
|
|
"""Объединения профиля и конф. файла
|
|
|
|
|
|
|
|
|
@ -2260,21 +2268,24 @@ class profile(_file, _terms):
|
|
|
|
|
ListOptTitle - список строк которые добавятся в заголовок
|
|
|
|
|
"""
|
|
|
|
|
# Выполняем условия для блока текста а так-же заменяем переменные
|
|
|
|
|
self.newProfile = ""
|
|
|
|
|
self.nameFileNew = self.absFileName(newFile)
|
|
|
|
|
self.FN = self.openNewFile(self.nameFileNew)
|
|
|
|
|
self.newProfile = self.FN.read()
|
|
|
|
|
self.closeNewFile()
|
|
|
|
|
copyFile = True
|
|
|
|
|
if self.getFileType() != "bin":
|
|
|
|
|
# Вычисляем условные блоки
|
|
|
|
|
self.newProfile = self.applyTermsProfile(self.newProfile,
|
|
|
|
|
newFile)
|
|
|
|
|
#print "|%s|" %(self.newProfile)
|
|
|
|
|
# Заменяем переменные на их значения
|
|
|
|
|
self.newProfile = self.applyVarsProfile(self.newProfile)
|
|
|
|
|
self.newProfile = self.applyVarsProfile(self.newProfile,
|
|
|
|
|
newFile)
|
|
|
|
|
# Вычисляем функции
|
|
|
|
|
self.newProfile = self.applyFuncProfile(self.newProfile)
|
|
|
|
|
|
|
|
|
|
objHeadNew = self.__getApplyHeadProfile(newFile, oldFile)
|
|
|
|
|
self.newProfile = self.applyFuncProfile(self.newProfile,
|
|
|
|
|
newFile)
|
|
|
|
|
copyFile = False
|
|
|
|
|
objHeadNew = self.__getApplyHeadProfile(newFile, oldFile, copyFile)
|
|
|
|
|
if not objHeadNew:
|
|
|
|
|
return True
|
|
|
|
|
self.newProfile = objHeadNew.body
|
|
|
|
@ -2296,7 +2307,6 @@ class profile(_file, _terms):
|
|
|
|
|
# Тестирование
|
|
|
|
|
#print self.nameFileOld
|
|
|
|
|
#print objHeadNew.typeAppend
|
|
|
|
|
|
|
|
|
|
if objHeadNew.fileType:
|
|
|
|
|
# Создаем объект в случае параметра format в заголовке
|
|
|
|
|
if (objHeadNew.typeAppend == "replace" or\
|
|
|
|
|