|
|
|
@ -329,32 +329,20 @@ class fileHeader(_terms):
|
|
|
|
|
incorrectParams = set([])
|
|
|
|
|
# Удаление Заголовка Calculate
|
|
|
|
|
if comment:
|
|
|
|
|
titleFirst = _("Modified")
|
|
|
|
|
# В случае текста XML
|
|
|
|
|
if type(comment) == types.TupleType and len(comment) == 2:
|
|
|
|
|
_titleList = (_("Modified"), _("File of a template"))
|
|
|
|
|
reCalcHeader =\
|
|
|
|
|
re.compile(u"\s*%s\s+%s.+Calculate.+\s+%s.+\s+%s\s?"%(\
|
|
|
|
|
comment[0],
|
|
|
|
|
_titleList[0].decode("UTF-8"),
|
|
|
|
|
_titleList[1].decode("UTF-8"),
|
|
|
|
|
comment[1],
|
|
|
|
|
),
|
|
|
|
|
re.M|re.I|re.U)
|
|
|
|
|
textUnicode = text.decode("UTF-8")
|
|
|
|
|
reS = reCalcHeader.search(textUnicode)
|
|
|
|
|
re.compile("\s*%s\s+%s.+\s+(.+\n)+%s\s?"\
|
|
|
|
|
%(comment[0], titleFirst, comment[1]),re.M|re.I)
|
|
|
|
|
reS = reCalcHeader.search(text)
|
|
|
|
|
if reS:
|
|
|
|
|
textBody = textUnicode[:reS.start()]+textUnicode[reS.end():]
|
|
|
|
|
if textBody:
|
|
|
|
|
self.body = textBody.encode("UTF-8")
|
|
|
|
|
self.body = text[:reS.start()]+text[reS.end():]
|
|
|
|
|
else:
|
|
|
|
|
reCalcHeader =\
|
|
|
|
|
re.compile("\s*%s\-+\s+%s.+Calculate.+\s+%s.+\s+%s\-+\s?"%(\
|
|
|
|
|
comment,
|
|
|
|
|
comment,
|
|
|
|
|
comment,
|
|
|
|
|
comment,
|
|
|
|
|
),
|
|
|
|
|
re.M|re.I)
|
|
|
|
|
reCalcHeader = re.compile(\
|
|
|
|
|
"\s*%s\-+\s+%s\s+%s.+\s+(%s.+\s+)+%s\-+\s?"\
|
|
|
|
|
%(comment, comment, titleFirst ,comment,comment),
|
|
|
|
|
re.M|re.I)
|
|
|
|
|
reS = reCalcHeader.search(text)
|
|
|
|
|
if reS:
|
|
|
|
|
self.body = text[reS.end():]
|
|
|
|
@ -3042,7 +3030,7 @@ class template(_file, _terms, xmlShare, templateFormat, _shareTemplate):
|
|
|
|
|
self.__titleHead = "--------------------------------------\
|
|
|
|
|
----------------------------------------"
|
|
|
|
|
self._titleBody = ""
|
|
|
|
|
self._titleList = (_("Modified"), _("File of a template"))
|
|
|
|
|
self._titleList = (_("Modified"), _("Processed template files") + ":")
|
|
|
|
|
self._reVar = re.compile(("%s[a-zA-Z0-9_-]+%s")%(self.varStart,
|
|
|
|
|
self.varEnd),re.M)
|
|
|
|
|
# Условия
|
|
|
|
@ -3090,6 +3078,9 @@ re.M|re.S)
|
|
|
|
|
self.uid, self.gid, self.homeDir = self.getDataUser()
|
|
|
|
|
# Домашняя директория, плюс базовая директория
|
|
|
|
|
self.homeDir = os.path.join(self._baseDir, self.homeDir[1:])
|
|
|
|
|
# Глобальный словарь обработанных шаблонов файлов
|
|
|
|
|
# {путь к конф. файлу:[имена шаблонов] ...}
|
|
|
|
|
self.dictProcessedTemplates = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Преобразование восьмеричного в целое (ввод строка, вывод число)
|
|
|
|
@ -3263,14 +3254,19 @@ re.M|re.S)
|
|
|
|
|
else:
|
|
|
|
|
self._titleBody = commentFirst + self.__titleHead + "\n"
|
|
|
|
|
z = 0
|
|
|
|
|
lenCommentList = len(commentList) - 1
|
|
|
|
|
for com in self._titleList:
|
|
|
|
|
if lenCommentList < z:
|
|
|
|
|
self._titleBody += commentInsert + " " + com + "\n"
|
|
|
|
|
flagFirst = True
|
|
|
|
|
for com in list(self._titleList) + [""]*(len(commentList)):
|
|
|
|
|
if com:
|
|
|
|
|
if flagFirst:
|
|
|
|
|
self._titleBody += commentInsert + " " + com + " "+\
|
|
|
|
|
self.programVersion + "\n"
|
|
|
|
|
flagFirst = False
|
|
|
|
|
else:
|
|
|
|
|
self._titleBody += commentInsert + " " + com + "\n"
|
|
|
|
|
else:
|
|
|
|
|
self._titleBody += commentInsert + " " + com +\
|
|
|
|
|
" " + commentList[z] + "\n"
|
|
|
|
|
z += 1
|
|
|
|
|
self._titleBody += commentInsert + " " +\
|
|
|
|
|
commentList[z] + "\n"
|
|
|
|
|
z += 1
|
|
|
|
|
if flagList:
|
|
|
|
|
self._titleBody += commentLast +"\n"
|
|
|
|
|
else:
|
|
|
|
@ -3440,16 +3436,13 @@ re.M|re.S)
|
|
|
|
|
# файл в системе без условий
|
|
|
|
|
nameFileConfig = "/".join(map(lambda x:x.split("?")[0],\
|
|
|
|
|
nameFileConfig.split("/")))
|
|
|
|
|
listTemplTitle = prefix.split("/")[-2:]
|
|
|
|
|
templTitle = '"' + "/".join(listTemplTitle) + '"'
|
|
|
|
|
# Записываем в переменную обрабатываемый файл
|
|
|
|
|
self.objVar.Set("cl_pass_file",nameFileConfig)
|
|
|
|
|
# Пишем время модификации *.env файлов
|
|
|
|
|
if nameFileConfig.endswith(".env"):
|
|
|
|
|
nameEnvFile = os.path.split(nameFileConfig)[1]
|
|
|
|
|
self.functObj.timeConfigsIni[nameEnvFile] = float(time.time())
|
|
|
|
|
filesApl = self.join(path, nameFileConfig,(self.programVersion,
|
|
|
|
|
templTitle), optFile)
|
|
|
|
|
filesApl = self.joinTemplate(path, nameFileConfig, optFile)
|
|
|
|
|
if self.getError():
|
|
|
|
|
return False
|
|
|
|
|
if filesApl:
|
|
|
|
@ -3994,6 +3987,9 @@ re.M|re.S)
|
|
|
|
|
not objHeadNew.params.has_key("symbolic") and\
|
|
|
|
|
objHeadNew.params.has_key("link"):
|
|
|
|
|
return (applyFiles, False)
|
|
|
|
|
if not pathOldFile in self.dictProcessedTemplates:
|
|
|
|
|
self.dictProcessedTemplates[pathOldFile] = []
|
|
|
|
|
self.dictProcessedTemplates[pathOldFile].append(nameFileTemplate)
|
|
|
|
|
return (applyFiles, objHeadNew)
|
|
|
|
|
|
|
|
|
|
def createNewClass(self, name, bases, attrs={}):
|
|
|
|
@ -4032,7 +4028,7 @@ re.M|re.S)
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def join(self, nameFileTemplate, nameFileConfig, ListOptTitle, optFile):
|
|
|
|
|
def joinTemplate(self,nameFileTemplate, nameFileConfig ,optFile):
|
|
|
|
|
"""Объединения шаблона и конф. файла
|
|
|
|
|
|
|
|
|
|
join(nameFileTemplate, nameFileConfig, ListOptTitle)
|
|
|
|
@ -4086,12 +4082,14 @@ re.M|re.S)
|
|
|
|
|
if not self.fileIsUtf(nameFileConfig):
|
|
|
|
|
flagNotUtf8Old = True
|
|
|
|
|
self.textTemplate = objHeadNew.body
|
|
|
|
|
|
|
|
|
|
# Список примененных шаблонов
|
|
|
|
|
ListOptTitle = []
|
|
|
|
|
if nameFileConfig in self.dictProcessedTemplates:
|
|
|
|
|
ListOptTitle = self.dictProcessedTemplates[nameFileConfig]
|
|
|
|
|
# Титл конфигурационного файла
|
|
|
|
|
title = ""
|
|
|
|
|
if ListOptTitle:
|
|
|
|
|
title = self.getTitle(objHeadNew.comment,
|
|
|
|
|
ListOptTitle)
|
|
|
|
|
title = self.getTitle(objHeadNew.comment, ListOptTitle)
|
|
|
|
|
title = title.encode("UTF-8")
|
|
|
|
|
|
|
|
|
|
objHeadOld = False
|
|
|
|
|