|
|
|
@ -308,7 +308,7 @@ class fileHeader(_terms):
|
|
|
|
|
# Символ комментария
|
|
|
|
|
comment = False
|
|
|
|
|
# Выражение для поиска строки интерпретатора
|
|
|
|
|
reExecStr = re.compile("^#!.+\s*",re.I)
|
|
|
|
|
reExecStr = re.compile("^#!.+\s*",re.M)
|
|
|
|
|
# условные операторы
|
|
|
|
|
terms = ('>', '<', '==', '!=', '>=', '<=')
|
|
|
|
|
# параметры без значения
|
|
|
|
@ -326,11 +326,12 @@ class fileHeader(_terms):
|
|
|
|
|
# некорректные параметры
|
|
|
|
|
incorrectParams = []
|
|
|
|
|
# Поиск строки запустка (#!/bin/bash и.т. д)
|
|
|
|
|
if comment or (fileType != False and fileType!="bin"):
|
|
|
|
|
if comment or fileType!="bin":
|
|
|
|
|
reExecRes = self.reExecStr.search(self.body)
|
|
|
|
|
if reExecRes:
|
|
|
|
|
self.execStr = self.body[reExecRes.start():reExecRes.end()]
|
|
|
|
|
self.body = self.body[reExecRes.end():]
|
|
|
|
|
self.body = self.body[:reExecRes.start()] +\
|
|
|
|
|
self.body[reExecRes.end():]
|
|
|
|
|
# Удаление Заголовка Calculate
|
|
|
|
|
if comment:
|
|
|
|
|
titleFirst = _("Modified")
|
|
|
|
@ -339,24 +340,24 @@ class fileHeader(_terms):
|
|
|
|
|
reCalcHeader =\
|
|
|
|
|
re.compile("\s*%s\s+%s.+\s+(.+\n)+%s\s?"\
|
|
|
|
|
%(comment[0], titleFirst, comment[1]),re.M|re.I)
|
|
|
|
|
reS = reCalcHeader.search(text)
|
|
|
|
|
reS = reCalcHeader.search(self.body)
|
|
|
|
|
if reS:
|
|
|
|
|
self.body = text[:reS.start()]+text[reS.end():]
|
|
|
|
|
self.body = self.body[:reS.start()]+self.body[reS.end():]
|
|
|
|
|
else:
|
|
|
|
|
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)
|
|
|
|
|
reS = reCalcHeader.search(self.body)
|
|
|
|
|
if reS:
|
|
|
|
|
self.body = text[reS.end():]
|
|
|
|
|
self.body = self.body[reS.end():]
|
|
|
|
|
if fileType != False:
|
|
|
|
|
if fileType=="bin":
|
|
|
|
|
self.params["format"] = fileType
|
|
|
|
|
self.fileType = self._getType()
|
|
|
|
|
self.typeAppend = self._getAppend()
|
|
|
|
|
else:
|
|
|
|
|
textLines = text.splitlines()
|
|
|
|
|
textLines = self.body.splitlines()
|
|
|
|
|
if textLines:
|
|
|
|
|
textLine = textLines[0]
|
|
|
|
|
rePar = re.compile("\s*#\s*calculate\s+",re.I)
|
|
|
|
@ -364,17 +365,17 @@ class fileHeader(_terms):
|
|
|
|
|
if reP:
|
|
|
|
|
reL = False
|
|
|
|
|
reLns = re.compile(r"\A([^\\\n]*\\\n)+[^\n]*\n*",re.M)
|
|
|
|
|
reLs = reLns.search(text)
|
|
|
|
|
reLs = reLns.search(self.body)
|
|
|
|
|
if reLs:
|
|
|
|
|
reL = reLs
|
|
|
|
|
paramLine = text[reP.end():reLs.end()]
|
|
|
|
|
paramLine = self.body[reP.end():reLs.end()]
|
|
|
|
|
paramLine = paramLine.replace("\\"," ")
|
|
|
|
|
else:
|
|
|
|
|
reLn = re.compile("\n")
|
|
|
|
|
reL = reLn.search(text)
|
|
|
|
|
reL = reLn.search(self.body)
|
|
|
|
|
paramLine = textLine[reP.end():]
|
|
|
|
|
if reL:
|
|
|
|
|
self.body = text[reL.end():]
|
|
|
|
|
self.body = self.body[reL.end():]
|
|
|
|
|
else:
|
|
|
|
|
self.body = ""
|
|
|
|
|
paramList = re.split("\s+",paramLine)
|
|
|
|
@ -417,7 +418,7 @@ class fileHeader(_terms):
|
|
|
|
|
else:
|
|
|
|
|
self.headerTerm = False
|
|
|
|
|
self.setError(_("incorrect header parameters - '%s'")\
|
|
|
|
|
%"append=%s"%self.params["append"])
|
|
|
|
|
%"append=%s"%self.params["append"])
|
|
|
|
|
if not incorrectParams and self.params:
|
|
|
|
|
incorrectParams = set(self.params.keys()) - set(self.allowParam)
|
|
|
|
|
if incorrectParams:
|
|
|
|
@ -545,7 +546,13 @@ class dirHeader(_terms):
|
|
|
|
|
incorrectParams = set([i])
|
|
|
|
|
elif len(par) == 2:
|
|
|
|
|
self.params[par[0]] = par[1]
|
|
|
|
|
self.typeAppend = self._getAppend()
|
|
|
|
|
typeAppend = self._getAppend()
|
|
|
|
|
if typeAppend:
|
|
|
|
|
self.typeAppend = typeAppend
|
|
|
|
|
else:
|
|
|
|
|
self.headerTerm = False
|
|
|
|
|
self.setError(_("incorrect header parameters - '%s'")\
|
|
|
|
|
%"append=%s"%self.params["append"])
|
|
|
|
|
if not flagErrorBody:
|
|
|
|
|
if not incorrectParams:
|
|
|
|
|
incorrectParams = set(self.params.keys()) - set(self.allowParam)
|
|
|
|
@ -556,9 +563,11 @@ class dirHeader(_terms):
|
|
|
|
|
|
|
|
|
|
def _getAppend(self):
|
|
|
|
|
"""Выдать тип добавления директории"""
|
|
|
|
|
if self.params.has_key("append") and self.params["append"] in\
|
|
|
|
|
self._fileAppend:
|
|
|
|
|
return self.params["append"]
|
|
|
|
|
if self.params.has_key("append"):
|
|
|
|
|
if self.params["append"] in self._fileAppend:
|
|
|
|
|
return self.params["append"]
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
else:
|
|
|
|
|
return "join"
|
|
|
|
|
|
|
|
|
@ -4355,7 +4364,6 @@ re.M|re.S)
|
|
|
|
|
configFileType = self.getFileType(nameFileConfig)
|
|
|
|
|
objHeadOld = fileHeader(nameFileConfig, self.textConfig,
|
|
|
|
|
fileType=configFileType)
|
|
|
|
|
|
|
|
|
|
# Строка вызова скрипта (#!/bin/bash ...)
|
|
|
|
|
execStr = ""
|
|
|
|
|
if objHeadNew.execStr:
|
|
|
|
@ -4454,7 +4462,7 @@ re.M|re.S)
|
|
|
|
|
self.textConfig = title + self.textTemplate
|
|
|
|
|
self.saveConfFile()
|
|
|
|
|
return filesApply
|
|
|
|
|
# Впереди
|
|
|
|
|
# Вверху
|
|
|
|
|
elif typeAppendTemplate == "before":
|
|
|
|
|
if "xml_" in formatTemplate:
|
|
|
|
|
self.setError(\
|
|
|
|
@ -4474,7 +4482,7 @@ re.M|re.S)
|
|
|
|
|
|
|
|
|
|
self.saveConfFile()
|
|
|
|
|
return filesApply
|
|
|
|
|
# Cзади
|
|
|
|
|
# Внизу
|
|
|
|
|
elif typeAppendTemplate == "after":
|
|
|
|
|
if "xml_" in formatTemplate:
|
|
|
|
|
self.setError(\
|
|
|
|
|