|
|
|
@ -1011,7 +1011,8 @@ class fileHeader(HParams, _terms):
|
|
|
|
|
if reS:
|
|
|
|
|
self.body = self.body[reS.end():]
|
|
|
|
|
if fileType is not False:
|
|
|
|
|
if fileType == "bin":
|
|
|
|
|
headerLine = Template.getHeaderText(text, binary = fileType == "bin")
|
|
|
|
|
if fileType == "bin" and not headerLine:
|
|
|
|
|
self.params[HParams.Format] = fileType
|
|
|
|
|
self.fileType = self._getType()
|
|
|
|
|
self.typeAppend = self._getAppend()
|
|
|
|
@ -1019,26 +1020,33 @@ class fileHeader(HParams, _terms):
|
|
|
|
|
textLines = self.body.splitlines()
|
|
|
|
|
if textLines:
|
|
|
|
|
textLine = textLines[0]
|
|
|
|
|
if fileType == "bin" and headerLine:
|
|
|
|
|
textLine = textLine.decode("UTF-8")
|
|
|
|
|
#py3 regex problems
|
|
|
|
|
rePar = re.compile(
|
|
|
|
|
"\s*#\s*calculate\s+\\\\?|\s*#\s*calculate\\\\?$", re.I)
|
|
|
|
|
reP = rePar.search(textLine)
|
|
|
|
|
if reP:
|
|
|
|
|
reLns = re.compile(r"\A([^\\\n]*\\\n)+[^\n]*\n*", re.M)
|
|
|
|
|
reg = r"\A([^\\\n]*\\\n)+[^\n]*\n*" if fileType != "bin" else \
|
|
|
|
|
rb"\A([^\\\n]*\\\n)+[^\n]*\n*"
|
|
|
|
|
reg_split = "\n" if fileType != "bin" else b"\n"
|
|
|
|
|
reLns = re.compile(reg, re.M)
|
|
|
|
|
reLs = reLns.search(self.body)
|
|
|
|
|
if reLs:
|
|
|
|
|
reL = reLs
|
|
|
|
|
paramLine = self.body[reP.end():reLs.end()]
|
|
|
|
|
paramLine = paramLine.replace("\\", " ")
|
|
|
|
|
# paramLine = self.body[reP.end():reLs.end()]
|
|
|
|
|
# if fileType == "bin":
|
|
|
|
|
# paramLine = paramLine.decode("UTF-8")
|
|
|
|
|
# paramLine = paramLine.replace("\\", " ")
|
|
|
|
|
else:
|
|
|
|
|
reLn = re.compile("\n")
|
|
|
|
|
reLn = re.compile(reg_split)
|
|
|
|
|
reL = reLn.search(self.body)
|
|
|
|
|
paramLine = textLine[reP.end():]
|
|
|
|
|
# paramLine = textLine[reP.end():]
|
|
|
|
|
if reL:
|
|
|
|
|
self.body = self.body[reL.end():]
|
|
|
|
|
else:
|
|
|
|
|
self.body = ""
|
|
|
|
|
paramList = self.splitParLine(paramLine)
|
|
|
|
|
paramList = self.splitParLine(headerLine)
|
|
|
|
|
if paramList:
|
|
|
|
|
for i in paramList:
|
|
|
|
|
for term in self.terms:
|
|
|
|
@ -4293,7 +4301,8 @@ gettext -d cl_template "$*"
|
|
|
|
|
return origfilename
|
|
|
|
|
return origfilename
|
|
|
|
|
|
|
|
|
|
def getHeaderText(self, text, binary=False):
|
|
|
|
|
@staticmethod
|
|
|
|
|
def getHeaderText(text, binary=False):
|
|
|
|
|
textLines = text.splitlines()
|
|
|
|
|
paramLine = ""
|
|
|
|
|
if textLines:
|
|
|
|
|