|
|
|
@ -1886,7 +1886,7 @@ class profile(_file, _terms):
|
|
|
|
|
varStart = "#-"
|
|
|
|
|
varEnd = "-#"
|
|
|
|
|
self._reVar = re.compile(("%s[a-zA-Z0-9_-]+%s")%(varStart,varEnd),re.M)
|
|
|
|
|
self._reFunc = re.compile(("%s[a-zA-Z0-9_\-\+\(\)\, \*\/]+%s")\
|
|
|
|
|
self._reFunc = re.compile(("%s[a-zA-Z0-9_\-\+\(\)\, \*\/\.]+%s")\
|
|
|
|
|
%(varStart,varEnd),re.M)
|
|
|
|
|
self._deltVarStart = len(varStart)
|
|
|
|
|
self._deltVarEnd = len(varEnd)
|
|
|
|
@ -1945,7 +1945,7 @@ class profile(_file, _terms):
|
|
|
|
|
return textProfileTmp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def applyFuncProfile(self, textProfile, nameProfile):
|
|
|
|
|
def applyFuncProfile(self, textProfile, nameProfile, nameSystemFile):
|
|
|
|
|
""" Применяет функции к тексту профиля
|
|
|
|
|
"""
|
|
|
|
|
def equalTerm(term, sNum, sMD, localVars):
|
|
|
|
@ -2029,8 +2029,41 @@ class profile(_file, _terms):
|
|
|
|
|
exit(1)
|
|
|
|
|
return textProfileTmp
|
|
|
|
|
|
|
|
|
|
def funcLoad(resS,localVarsLoad,textProfileTmp):
|
|
|
|
|
"""если файл существует читает из файла локальную переменную
|
|
|
|
|
|
|
|
|
|
если один параметр - выводит значение локальной переменной
|
|
|
|
|
"""
|
|
|
|
|
terms = funTxt[5:-1].replace(" ","").split(",")
|
|
|
|
|
# Название локальной переменной
|
|
|
|
|
nameLocVar = terms[0]
|
|
|
|
|
if not localVarsLoad.has_key(nameLocVar):
|
|
|
|
|
localVarsLoad[nameLocVar] = ""
|
|
|
|
|
if len(terms) == 2:
|
|
|
|
|
if terms[1].strip():
|
|
|
|
|
fileName = terms[1].strip()
|
|
|
|
|
if fileName[1] != "/":
|
|
|
|
|
path = os.path.split(nameSystemFile)[0]
|
|
|
|
|
fileName=os.path.join(path,fileName)
|
|
|
|
|
if os.path.exists(fileName):
|
|
|
|
|
FD = open(fileName)
|
|
|
|
|
localVarsLoad[nameLocVar] = FD.read().strip()
|
|
|
|
|
FD.close
|
|
|
|
|
if not terms[0].strip() or\
|
|
|
|
|
(len(terms)==2 and not terms[1].strip()) or\
|
|
|
|
|
len(terms)>2:
|
|
|
|
|
print _("error in profile %s")%nameProfile
|
|
|
|
|
print _("error profile term %s")%str(funTxt)
|
|
|
|
|
exit(1)
|
|
|
|
|
replace = localVarsLoad[nameLocVar]
|
|
|
|
|
textProfileTmp = textProfileTmp[:resS.start()] + replace +\
|
|
|
|
|
textProfileTmp[resS.end():]
|
|
|
|
|
return textProfileTmp
|
|
|
|
|
|
|
|
|
|
# Локальные переменные
|
|
|
|
|
localVars = {}
|
|
|
|
|
# Локальные переменные для функции load
|
|
|
|
|
localVarsLoad = {}
|
|
|
|
|
# Регулярное выражние для сложения
|
|
|
|
|
sNum = re.compile("\-[^\-\+]+|[^\-\+]+")
|
|
|
|
|
# Регулярное выражение для умножениея и деления
|
|
|
|
@ -2040,9 +2073,14 @@ class profile(_file, _terms):
|
|
|
|
|
while resS:
|
|
|
|
|
mark = textProfileTmp[resS.start():resS.end()]
|
|
|
|
|
funTxt = mark[self._deltVarStart:-self._deltVarEnd]
|
|
|
|
|
# Функция sum
|
|
|
|
|
if funTxt[:4] == "sum(":
|
|
|
|
|
textProfileTmp = funcSum(funTxt,resS,localVars,textProfileTmp)
|
|
|
|
|
resS = self._reFunc.search(textProfileTmp)
|
|
|
|
|
# Функция load
|
|
|
|
|
elif funTxt[:5] == "load(":
|
|
|
|
|
textProfileTmp = funcLoad(resS,localVarsLoad,textProfileTmp)
|
|
|
|
|
resS = self._reFunc.search(textProfileTmp)
|
|
|
|
|
else:
|
|
|
|
|
resS = False
|
|
|
|
|
return textProfileTmp
|
|
|
|
@ -2363,7 +2401,7 @@ class profile(_file, _terms):
|
|
|
|
|
newFile)
|
|
|
|
|
# Вычисляем функции
|
|
|
|
|
self.newProfile = self.applyFuncProfile(self.newProfile,
|
|
|
|
|
newFile)
|
|
|
|
|
newFile, oldFile)
|
|
|
|
|
copyFile = False
|
|
|
|
|
filesApply, objHeadNew = self.__getApplyHeadProfile(newFile, oldFile,
|
|
|
|
|
copyFile)
|
|
|
|
|