Feature: изменена логика сохранения имен шаблонов в шапке файлов

master 3.7.3.6
root 1 year ago
parent 43fe367261
commit 17019fd682

@ -4196,6 +4196,27 @@ gettext -d cl_template "$*"
self.setError(_("invalid template name: ") + str(fileTemplate))
return False
def getPrevComments(self, file_path, titlehead):
if not os.path.exists(file_path):
return []
with open(file_path) as inf:
commentsList = []
countTitle = 0
for line in inf.readlines():
if titlehead in line:
countTitle += 1
if countTitle > 1:
break
continue
elif any(x in line for x in self._titleList if x !=':'):
continue
else:
line = line.replace("#", '').strip()
if os.path.exists(line):
commentsList.append(line)
return commentsList
def getTitle(self, comment, commentList, configPath=""):
"""Выдает заголовок шаблона ( версия и.т.д)"""
origConfigPath = PkgContents.reCfg.sub("/", configPath)
@ -6446,6 +6467,8 @@ gettext -d cl_template "$*"
objTemplNew.setNameBodyNode(nameRootNode)
# Титл для объединения
if ListOptTitle:
prevComments = self.getPrevComments(nameFileConfig, self.__titleHead)
ListOptTitle = prevComments + [x for x in ListOptTitle if x not in prevComments]
title = self.getTitle(objTemplNew._comment,
ListOptTitle,
configPath=nameFileConfig)

Loading…
Cancel
Save