|
|
|
@ -2377,6 +2377,17 @@ class profile(_file, _terms):
|
|
|
|
|
newCl = type(name, bases + (newMethod, object,), attrsNew)
|
|
|
|
|
return newCl
|
|
|
|
|
|
|
|
|
|
def fileIsUtf(self, fileName):
|
|
|
|
|
"""Проверяет файл на кодировку UTF-8"""
|
|
|
|
|
if os.path.exists(fileName):
|
|
|
|
|
FD = open(self.absFileName(fileName))
|
|
|
|
|
newProfile = FD.read()
|
|
|
|
|
FD.close()
|
|
|
|
|
try:
|
|
|
|
|
newProfile.decode("UTF-8")
|
|
|
|
|
except:
|
|
|
|
|
return False
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def join(self, newFile, oldFile, ListOptTitle):
|
|
|
|
|
"""Объединения профиля и конф. файла
|
|
|
|
@ -2392,6 +2403,15 @@ class profile(_file, _terms):
|
|
|
|
|
self.closeNewFile()
|
|
|
|
|
copyFile = True
|
|
|
|
|
if self.getFileType() != "bin":
|
|
|
|
|
# проверяем кодировку файлов
|
|
|
|
|
if not self.fileIsUtf(newFile):
|
|
|
|
|
self.setError(\
|
|
|
|
|
_("Can not decode file in UTF-8:") + " " + newFile)
|
|
|
|
|
return False
|
|
|
|
|
if not self.fileIsUtf(oldFile):
|
|
|
|
|
self.setError(\
|
|
|
|
|
_("Can not decode file in UTF-8:") + " " + oldFile)
|
|
|
|
|
return False
|
|
|
|
|
# Вычисляем условные блоки
|
|
|
|
|
self.newProfile = self.applyTermsProfile(self.newProfile,
|
|
|
|
|
newFile)
|
|
|
|
@ -2433,19 +2453,6 @@ class profile(_file, _terms):
|
|
|
|
|
objHeadNew.typeAppend == "after") and\
|
|
|
|
|
not (objHeadNew.fileType == "bin" or\
|
|
|
|
|
objHeadNew.fileType == "raw"):
|
|
|
|
|
# Проверка на декодирование файлов в UTF-8
|
|
|
|
|
try:
|
|
|
|
|
self.newProfile.decode("UTF-8")
|
|
|
|
|
except:
|
|
|
|
|
self.setError(/
|
|
|
|
|
_("Can not decode file in UTF-8:") + " " + newFile)
|
|
|
|
|
return False
|
|
|
|
|
try:
|
|
|
|
|
self.oldProfile.decode("UTF-8")
|
|
|
|
|
except:
|
|
|
|
|
self.setError(/
|
|
|
|
|
_("Can not decode file in UTF-8:") + " " + oldFile)
|
|
|
|
|
return False
|
|
|
|
|
try:
|
|
|
|
|
exec ("objProfNew=%s(self.newProfile)"%\
|
|
|
|
|
(objHeadNew.fileType))
|
|
|
|
|