You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
calculate-overlay/sys-apps/calculate-lib/files/calculate-lib-3.1.1_alpha2-...

113 lines
4.8 KiB

diff --git calculate/lib/cl_template.py calculate/lib/cl_template.py
index 24ad307..6739093 100644
--- calculate/lib/cl_template.py
+++ calculate/lib/cl_template.py
@@ -2799,6 +2799,33 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction):
else:
return ""
+ def funcPkgw(self, funArgv, resS, localVars, textTemplateTmp, nameTemp):
+ """Функция шаблона pkgw(), возвращает аргумент если программа установлена"""
+ # Название программы
+ nameProg = funArgv.replace(" ","")
+ origProg = nameProg
+ # Замена функции в тексте шаблона
+ replace = ""
+ if "/" in nameProg:
+ category, spl, nameProg = nameProg.partition("/")
+ nameProg, spl, slot = nameProg.partition(":")
+ if not category in self.installCategory:
+ self.getInstallPkgGentoo(category=category)
+ self.installCategory.append(category)
+ replace = self.pkg(nameProg, slot=slot or None)
+ else:
+ if not self.flagAllPkgScan:
+ self.getInstallPkgGentoo()
+ templateFunction.flagAllPkgScan = True
+ nameProg,spl,slot = nameProg.partition(":")
+ replace = self.pkg(nameProg,
+ slot=slot)
+ if replace:
+ replace = origProg
+ textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\
+ textTemplateTmp[resS.end():]
+ return textTemplateTmp
+
def funcPkg(self, funArgv, resS, localVars, textTemplateTmp, nameTemp):
"""Функция шаблона pkg(), выдает номер версии программы"""
# Название программы
@@ -2810,6 +2837,7 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction):
nameProg, spl, slot = nameProg.partition(":")
if not category in self.installCategory:
self.getInstallPkgGentoo(category=category)
+ self.installCategory.append(category)
replace = self.pkg(nameProg, slot=slot or None)
else:
if not self.flagAllPkgScan:
@@ -2894,6 +2922,31 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction):
textTemplateTmp[resS.end():]
return textTemplateTmp
+ def funcIn(self, funArgv, resS, localVars, textTemplateTmp, nameTemp):
+ """
+ Function in for check value in variable
+ """
+ terms = funArgv.replace(" ","").split(",")
+ # Название локальной переменной
+ nameLocVar = terms[0]
+ flagFoundVar = False
+ try:
+ value = self.objVar.Get(nameLocVar)
+ flagFoundVar = True
+ except:
+ pass
+ if flagFoundVar:
+ if value in terms[1:]:
+ replace = "1"
+ else:
+ replace = ""
+ else:
+ self.raiseErrTemplate(_("error: variable %s does not exist")\
+ %str(nameLocVar))
+ textTemplateTmp = textTemplateTmp[:resS.start()] + replace +\
+ textTemplateTmp[resS.end():]
+ return textTemplateTmp
+
def funcPush(self, funArgv, resS, localVars, textTemplateTmp, nameTemp):
"""локальная функция записывает значение переменной
diff --git calculate/lib/format/world.py calculate/lib/format/world.py
index 69bfc4f..36f8a69 100644
--- calculate/lib/format/world.py
+++ calculate/lib/format/world.py
@@ -26,7 +26,7 @@ class world(objShare):
configName = "world"
configVersion = "0.1"
sepFields = "\n"
- reComment = re.compile("[ \t]*%s" %(_comment))
+ reComment = re.compile("[ \t]*%s" %("#"))
reSepFields = re.compile(sepFields)
# разделитель названия и значения переменной
reSeparator = re.compile("=")
@@ -66,15 +66,15 @@ class world(objShare):
for k in txtLines:
textLine = k + endtxtLines[z]
z += 1
- #findComment = self.reComment.search(textLine)
+ findComment = self.reComment.search(textLine)
if not textLine.strip():
field.br = textLine
fields.append(field)
field = fieldData()
- #elif findComment:
- # field.comment = textLine
- # fields.append(field)
- # field = fieldData()
+ elif findComment:
+ field.comment = textLine
+ fields.append(field)
+ field = fieldData()
else:
pars = textLine.strip()
field.name = pars