develop
asamoukin 15 years ago
parent 416e751295
commit 8090b3b689

@ -143,6 +143,7 @@ class _terms(_error):
self.setError("'%s'"%term + " " + _("incorrect"))
self.setError(textError)
return False
flagIntTypeVar = None
if flagFunction:
valVars = function("#-%s-#"%vals[0])
if valVars == "":
@ -151,6 +152,19 @@ class _terms(_error):
self.setError("'%s'"%term + " " + _("incorrect"))
self.setError(textError)
return False
if "load" == searchFunct.group(1):
if re.search("\(\s*num\s*,",vals[0]):
if valVars:
try:
valVars = int(valVars)
except:
self.setError("'%s'"%term + " " + \
_("incorrect"))
self.setError (textError)
return False
flagIntTypeVar = True
else:
flagIntTypeVar = False
else:
try:
valVars = self.objVar.Get(vals[0])
@ -160,7 +174,9 @@ class _terms(_error):
exit(1)
# Cравниваем номера версий
if "_ver" in vals[0] or \
(flagFunction and "pkg" == searchFunct.group(1)):
(flagFunction and "pkg" == searchFunct.group(1)) or\
(flagFunction and "load" == searchFunct.group(1) and\
re.search("\(\s*ver\s*,",vals[0])):
verFile, verVar = self._convertVers(vals[1],valVars)
exec("res=("+"'"+verVar+"'"+sepF+"'"+verFile+"'"+")")
if res:
@ -168,11 +184,12 @@ class _terms(_error):
else:
listEqual.append("0")
else:
flagIntTypeVar = True
try:
valVars = int(valVars)
except:
flagIntTypeVar = False
if flagIntTypeVar == None:
flagIntTypeVar = True
try:
valVars = int(valVars)
except:
flagIntTypeVar = False
if flagIntTypeVar:
if not vals[1].strip():
vals[1] = 0
@ -2241,33 +2258,42 @@ class profile(_file, _terms,xmlShare):
exit(1)
return textProfileTmp
def funcLoad(resS,localVarsLoad,textProfileTmp):
def funcLoad(funTxt,resS,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\
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]
if len(terms) == 2:
if not terms[0] in ["ver","num","char","key"]:
print _("error in profile %s")%nameProfile
print _("error profile term %s")%str(funTxt)
print _("first argument function is not 'ver' or 'num' or\
'char'")
exit(1)
if len(terms) == 1:
fileName = terms[0].strip()
if fileName[0] != "/":
path = os.path.split(nameSystemFile)[0]
fileName=os.path.join(path,fileName)
else:
fileName = terms[1].strip()
if fileName[1] != "/":
path = os.path.split(nameSystemFile)[0]
fileName=os.path.join(path,fileName)
replace = ""
if os.path.exists(fileName):
FD = open(fileName)
replace = FD.read().strip()
FD.close
if terms[0] in ["ver","num"]:
replace = "0"
textProfileTmp = textProfileTmp[:resS.start()] + replace +\
textProfileTmp[resS.end():]
return textProfileTmp
@ -2416,8 +2442,6 @@ class profile(_file, _terms,xmlShare):
# Локальные переменные
localVars = {}
# Локальные переменные для функции load
localVarsLoad = {}
# Регулярное выражние для сложения
sNum = re.compile("\-[^\-\+]+|[^\-\+]+")
# Регулярное выражение для умножениея и деления
@ -2433,7 +2457,7 @@ class profile(_file, _terms,xmlShare):
resS = self._reFunc.search(textProfileTmp)
# Функция load
elif funTxt[:5] == "load(":
textProfileTmp = funcLoad(resS,localVarsLoad,textProfileTmp)
textProfileTmp = funcLoad(funTxt,resS,textProfileTmp)
resS = self._reFunc.search(textProfileTmp)
elif funTxt[:4] == "pkg(":
textProfileTmp = funcPkg(funTxt,resS,textProfileTmp)

Loading…
Cancel
Save