|
|
|
@ -473,9 +473,9 @@ class _terms(_error, _shareTermsFunction, _shareTemplate):
|
|
|
|
|
|
|
|
|
|
def fillSuffix(elemA, elemB, sA, svA, sB, svB):
|
|
|
|
|
if str(sA) or str(sB):
|
|
|
|
|
svA, svB = map(lambda x: [x] if x else ['0'], (svA, svB))
|
|
|
|
|
svA, svB = [[x] if x else ['0'] for x in (svA, svB)]
|
|
|
|
|
fillZero(svA, svB)
|
|
|
|
|
sA, sB = map(lambda x: x if x else 0, (sA, sB))
|
|
|
|
|
sA, sB = [x if x else 0 for x in (sA, sB)]
|
|
|
|
|
elemA.append(str(self._lenSuffixDict + sA))
|
|
|
|
|
elemA.extend(svA)
|
|
|
|
|
elemB.append(str(self._lenSuffixDict + sB))
|
|
|
|
@ -488,7 +488,7 @@ class _terms(_error, _shareTermsFunction, _shareTemplate):
|
|
|
|
|
elemB = vB.split(".")
|
|
|
|
|
fillZero(elemA, elemB)
|
|
|
|
|
if lA or lB:
|
|
|
|
|
lA, lB = map(lambda x: x if x else '0', (lA, lB))
|
|
|
|
|
lA, lB = [x if x else '0' for x in (lA, lB)]
|
|
|
|
|
elemA.append(lA)
|
|
|
|
|
elemB.append(lB)
|
|
|
|
|
|
|
|
|
@ -506,7 +506,7 @@ class _terms(_error, _shareTermsFunction, _shareTemplate):
|
|
|
|
|
fillSuffix(elemA, elemB, "", "", sB, svB)
|
|
|
|
|
|
|
|
|
|
if rvA or rvB:
|
|
|
|
|
rvA, rvB = map(lambda x: [x[1:]], (rvA, rvB))
|
|
|
|
|
rvA, rvB = [[x[1:]] for x in (rvA, rvB)]
|
|
|
|
|
fillZero(rvA, rvB)
|
|
|
|
|
elemA += rvA
|
|
|
|
|
elemB += rvB
|
|
|
|
@ -792,7 +792,7 @@ class _terms(_error, _shareTermsFunction, _shareTemplate):
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def splitQuote(listPar, quoteSymbol):
|
|
|
|
|
listTerm = map(lambda x: x + quoteSymbol, ("=", ">", "<"))
|
|
|
|
|
listTerm = [x + quoteSymbol for x in ("=", ">", "<")]
|
|
|
|
|
flagQ = False
|
|
|
|
|
mass = []
|
|
|
|
|
v = ""
|
|
|
|
@ -1944,7 +1944,7 @@ def template_function(lastall=False):
|
|
|
|
|
# число обязательных параметров
|
|
|
|
|
reqnum = varnum - defnum
|
|
|
|
|
if funArgv:
|
|
|
|
|
terms = map(lambda x: x.strip(), funArgv.split(","))
|
|
|
|
|
terms = [x.strip() for x in funArgv.split(",")]
|
|
|
|
|
else:
|
|
|
|
|
terms = []
|
|
|
|
|
|
|
|
|
@ -2075,13 +2075,12 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction,
|
|
|
|
|
if not self.templateFunction:
|
|
|
|
|
# префикс функций шаблона
|
|
|
|
|
pref = "func"
|
|
|
|
|
# cписок [(название функции, функция), ...]
|
|
|
|
|
dictFunc = filter(lambda x: x[0].startswith(pref) and \
|
|
|
|
|
hasattr(x[1], "__call__"),
|
|
|
|
|
self.__class__.__dict__.items())
|
|
|
|
|
# cписок [(название функции, функция), ...]
|
|
|
|
|
# удаляем у названия функции префикс и переводим остаток названия
|
|
|
|
|
# в нижний регистр
|
|
|
|
|
dictFunc = map(lambda x: (x[0][len(pref):].lower(), x[1]), dictFunc)
|
|
|
|
|
dictFunc = [(x[0][len(pref):].lower(), x[1]) for x
|
|
|
|
|
in self.__class__.__dict__.items()
|
|
|
|
|
if x[0].startswith(pref) and hasattr(x[1], "__call__")]
|
|
|
|
|
# Формируем словарь функций шаблона
|
|
|
|
|
self.templateFunction.update(dictFunc)
|
|
|
|
|
# Формируем список функций шаблона
|
|
|
|
@ -2391,7 +2390,7 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction,
|
|
|
|
|
если второй параметр root, то проверка осуществляется от корня.
|
|
|
|
|
"""
|
|
|
|
|
if funArgv.strip():
|
|
|
|
|
terms = map(lambda x: x.strip(), funArgv.split(","))
|
|
|
|
|
terms = [x.strip() for x in funArgv.split(",")]
|
|
|
|
|
if len(terms) > 2:
|
|
|
|
|
raise self.raiseErrTemplate()
|
|
|
|
|
fileName = terms[0]
|
|
|
|
@ -2480,8 +2479,7 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction,
|
|
|
|
|
if os.path.exists(fileName):
|
|
|
|
|
replace = readFile(fileName).strip()
|
|
|
|
|
if replace and lenTerms >= 2 and terms[0] == "empty":
|
|
|
|
|
replace = "\n".join(filter(lambda x: not self.reEmptyLoad.search(x),
|
|
|
|
|
replace.split("\n")))
|
|
|
|
|
replace = "\n".join((x for x in replace.split("\n") if not self.reEmptyLoad.search(x)))
|
|
|
|
|
if not replace and lenTerms >= 2 and terms[0] in ["ver", "num"]:
|
|
|
|
|
replace = "0"
|
|
|
|
|
textTemplateTmp = textTemplateTmp[:resS.start()] + replace + \
|
|
|
|
@ -3050,12 +3048,8 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction,
|
|
|
|
|
_("the first parameter must be the resolution"))
|
|
|
|
|
|
|
|
|
|
re_resol = re.compile(r".*?(\d+)x(\d+).*")
|
|
|
|
|
# res = list(map(lambda x: (int(x.group(1)), int(x.group(2)), x.group()),
|
|
|
|
|
# filter(None,
|
|
|
|
|
# map(re_resol.search,
|
|
|
|
|
# listDirectory(wpath)))))
|
|
|
|
|
res = [(int(x.group(1)), int(x.group(2)), x.group()) for x in
|
|
|
|
|
[re_resol.search(z) for z in listDirectory(wpath)] if x]
|
|
|
|
|
[re_resol.search(y) for y in listDirectory(wpath)] if x]
|
|
|
|
|
width = int(resol.group(1))
|
|
|
|
|
height = int(resol.group(2))
|
|
|
|
|
gep = sqrt(height ** 2 + width ** 2)
|
|
|
|
@ -3232,7 +3226,7 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction,
|
|
|
|
|
raise self.raiseErrTemplate()
|
|
|
|
|
return listArgv
|
|
|
|
|
|
|
|
|
|
terms = map(lambda x: x.strip(), funArgv.split(","))
|
|
|
|
|
terms = [x.strip() for x in funArgv.split(",")]
|
|
|
|
|
if len(terms) != 3:
|
|
|
|
|
raise self.raiseErrTemplate()
|
|
|
|
|
listArgv = getStrArgv(terms[:2])
|
|
|
|
@ -3325,7 +3319,7 @@ class templateFunction(_error, _warning, _shareTemplate, _shareTermsFunction,
|
|
|
|
|
"""Функция шаблона groups(),
|
|
|
|
|
проверяет нахождение пользователя в группах, если находится выдает '1'
|
|
|
|
|
"""
|
|
|
|
|
terms = map(lambda x: x.strip(), funArgv.split(","))
|
|
|
|
|
terms = [x.strip() for x in funArgv.split(",")]
|
|
|
|
|
groupNames = set(terms)
|
|
|
|
|
userGroups = set(self.groups)
|
|
|
|
|
replace = ""
|
|
|
|
@ -3768,11 +3762,9 @@ class ChangedFiles(object):
|
|
|
|
|
return self.pkgs
|
|
|
|
|
|
|
|
|
|
def getPkgFiles(self, pkg):
|
|
|
|
|
return map(lambda x: (x[0], x[1][0][1]),
|
|
|
|
|
filter(lambda x: x[1],
|
|
|
|
|
map(lambda x: (
|
|
|
|
|
x[0], filter(lambda x: x[0] == pkg, x[1])),
|
|
|
|
|
self.data.items())))
|
|
|
|
|
return [(x[0], x[1][0][1]) for x
|
|
|
|
|
in [(y[0], [z for z in y[1] if z[0] == pkg]) for y
|
|
|
|
|
in self.data.items()] if x[1]]
|
|
|
|
|
|
|
|
|
|
# modes work with configuration file
|
|
|
|
|
# T_ORIGIN - work with original config file
|
|
|
|
@ -4538,10 +4530,6 @@ gettext -d cl_template "$*"
|
|
|
|
|
filename = PkgContents.reCfg.sub("/", filename)
|
|
|
|
|
if not filename in self.cltObj.filterApplyTemplates:
|
|
|
|
|
self.cltObj.filterApplyTemplates[filename] = []
|
|
|
|
|
# pkgs = list(filter(
|
|
|
|
|
# lambda x: x not in
|
|
|
|
|
# self.cltObj.filterApplyTemplates[filename],
|
|
|
|
|
# list(map(lambda x: x[0], pkgs))))
|
|
|
|
|
pkgs = [x for x in [z[0] for z in pkgs]
|
|
|
|
|
if x not in self.cltObj.filterApplyTemplates[filename]]
|
|
|
|
|
self.cltObj.filterApplyTemplates[filename].extend(pkgs)
|
|
|
|
@ -4686,8 +4674,8 @@ gettext -d cl_template "$*"
|
|
|
|
|
elif action in (ChangedFiles.FILE_REMOVED,
|
|
|
|
|
ChangedFiles.DIR_REMOVED):
|
|
|
|
|
pkgContents.removeObject(filename)
|
|
|
|
|
files = set(map(lambda x: pathJoin(chrootPath, x),
|
|
|
|
|
pkgContents.content.keys()) + protected)
|
|
|
|
|
files = set([pathJoin(chrootPath, x) for x
|
|
|
|
|
in pkgContents.content.keys()] + protected)
|
|
|
|
|
if (self.objVar.Get('cl_dispatch_conf') != 'usenew' and
|
|
|
|
|
self.objVar.Get('cl_autoupdate_set') != "on"):
|
|
|
|
|
notUpdate = files - set(self.autoUpdateFiles)
|
|
|
|
@ -4844,8 +4832,8 @@ gettext -d cl_template "$*"
|
|
|
|
|
return False
|
|
|
|
|
nameFileConfig = path.partition(prefix)[2]
|
|
|
|
|
# файл в системе без условий
|
|
|
|
|
nameFileConfig = "/".join(map(lambda x: x.split("?")[0],
|
|
|
|
|
nameFileConfig.split("/")))
|
|
|
|
|
nameFileConfig = "/".join((x.split("?")[0] for x in nameFileConfig.split("/")))
|
|
|
|
|
|
|
|
|
|
# Записываем в переменную обрабатываемый файл
|
|
|
|
|
self.objVar.Set("cl_pass_file", os.path.basename(nameFileConfig))
|
|
|
|
|
self.headerParams = None
|
|
|
|
@ -4877,7 +4865,7 @@ gettext -d cl_template "$*"
|
|
|
|
|
return None
|
|
|
|
|
dirInfoFile = os.path.join(path, self.templDirNameFile)
|
|
|
|
|
newDir = pathJoin(self._baseDir, path.partition(prefix)[2])
|
|
|
|
|
newDir = "/".join(map(lambda x: x.split("?")[0], newDir.split("/")))
|
|
|
|
|
newDir = "/".join((x.split("?")[0]) for x in newDir.split("/"))
|
|
|
|
|
# Применяем шаблон
|
|
|
|
|
pathDir, objHeadDir, createdDirs = \
|
|
|
|
|
self.getApplyHeadDir(newDir, dirInfoFile, opt)
|
|
|
|
@ -5364,11 +5352,9 @@ gettext -d cl_template "$*"
|
|
|
|
|
passwdFile = os.path.join(self._baseDir, 'etc/passwd')
|
|
|
|
|
if os.path.exists(passwdFile):
|
|
|
|
|
with open(passwdFile, 'r') as f:
|
|
|
|
|
mapUid = dict(
|
|
|
|
|
filter(lambda x: x and len(x) > 1 and x[0] and x[1],
|
|
|
|
|
map(lambda x: x.split(':')[0:3:2],
|
|
|
|
|
filter(lambda x: not x.startswith('#'),
|
|
|
|
|
f))))
|
|
|
|
|
mapUid = dict([x for x in [y.split(':')[0:3:2] for y
|
|
|
|
|
in f if not y.startswith('#')]
|
|
|
|
|
if x and len(x) > 1 and x[0] and x[1]])
|
|
|
|
|
if strUid in mapUid:
|
|
|
|
|
return int(mapUid[strUid])
|
|
|
|
|
return None
|
|
|
|
@ -5378,11 +5364,9 @@ gettext -d cl_template "$*"
|
|
|
|
|
groupFile = os.path.join(self._baseDir, 'etc/group')
|
|
|
|
|
if os.path.exists(groupFile):
|
|
|
|
|
with open(groupFile, 'r') as f:
|
|
|
|
|
mapGid = dict(
|
|
|
|
|
filter(lambda x: x and len(x) > 1 and x[0] and x[1],
|
|
|
|
|
map(lambda x: x.split(':')[0:3:2],
|
|
|
|
|
filter(lambda x: not x.startswith('#'),
|
|
|
|
|
f))))
|
|
|
|
|
mapGid = dict([x for x in [y.split(':')[0:3:2] for y
|
|
|
|
|
in f if not y.startswith('#')]
|
|
|
|
|
if x and len(x) > 1 and x[0] and x[1]])
|
|
|
|
|
if strGid in mapGid:
|
|
|
|
|
return int(mapGid[strGid])
|
|
|
|
|
return None
|
|
|
|
@ -5393,14 +5377,8 @@ gettext -d cl_template "$*"
|
|
|
|
|
"""
|
|
|
|
|
# if file in PROTECT_MASK or not in PROTECT
|
|
|
|
|
chrootPath = self.objVar.Get('cl_chroot_path')
|
|
|
|
|
# if not list(filter(pathFile.startswith,
|
|
|
|
|
# map(lambda x: pathJoin(chrootPath, x),
|
|
|
|
|
# self.objVar.Get('cl_config_protect')))) or \
|
|
|
|
|
# list(filter(pathFile.startswith,
|
|
|
|
|
# map(lambda x: pathJoin(chrootPath, x),
|
|
|
|
|
# self.objVar.Get('cl_config_protect_mask')))):
|
|
|
|
|
if not [x for x in [pathJoin(chrootPath, y) for y in self.objVar.Get('cl_config_protect')] if pathFile.startswith(x)] or \
|
|
|
|
|
[x for x in [pathJoin(chrootPath, y) for y in self.objVar.Get('cl_config_protect_mask')] if pathFile.startswith(x)]:
|
|
|
|
|
[x for x in [pathJoin(chrootPath, y) for y in self.objVar.Get('cl_config_protect_mask')] if pathFile.startswith(x)]:
|
|
|
|
|
return pathFile
|
|
|
|
|
# if file was already modified by templates
|
|
|
|
|
if pathFile in self.changedFiles.data.keys():
|
|
|
|
@ -5916,7 +5894,7 @@ gettext -d cl_template "$*"
|
|
|
|
|
or HParams.Autoupdate in objHeadNew.params) and
|
|
|
|
|
not self.objVar.Get('cl_merge_pkg_pass')):
|
|
|
|
|
reCfg = re.compile(r"/._cfg\d{4}_", re.S)
|
|
|
|
|
self.autoUpdateFiles += map(lambda x: reCfg.sub('/', x), applyFiles)
|
|
|
|
|
self.autoUpdateFiles += [reCfg.sub('/', x) for x in applyFiles]
|
|
|
|
|
if pathOldFile not in self.dictProcessedTemplates:
|
|
|
|
|
self.dictProcessedTemplates[pathOldFile] = []
|
|
|
|
|
self.dictProcessedTemplates[pathOldFile].append(nameFileTemplate)
|
|
|
|
@ -6616,8 +6594,7 @@ class templateClt(scanDirectoryClt, Template):
|
|
|
|
|
origFileName = nameFileConfig
|
|
|
|
|
nameFileConfig = pathJoin(self._baseDir, nameFileConfig)
|
|
|
|
|
# файл в системе без условий
|
|
|
|
|
nameFileConfig = "/".join(map(lambda x: x.split("?")[0],
|
|
|
|
|
nameFileConfig.split("/")))
|
|
|
|
|
nameFileConfig = "/".join((x.split("?")[0] for x in nameFileConfig.split("/")))
|
|
|
|
|
# Записываем в переменную обрабатываемый файл
|
|
|
|
|
self.objVar.Set("cl_pass_file", os.path.basename(nameFileConfig))
|
|
|
|
|
self.headerParams = None
|
|
|
|
|