From c5e8c231b2dc85d80511ba56328e991d2cabc1eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B0=D0=BC=D0=BE=D1=83=D0=BA=D0=B8=D0=BD=20=D0=90?= =?UTF-8?q?=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Thu, 3 Sep 2009 14:35:47 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D1=85?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8=D0=BB=D1=8F=20=D0=B2=20=D1=83?= =?UTF-8?q?=D1=81=D0=BB=D0=BE=D0=B2=D0=BD=D0=BE=D0=B9=20=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=BA=D0=B5=20=D0=BF=D1=80=D0=BE=D1=84=D0=B8=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=B4=D0=B8=D1=80=D0=B5=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D0=B8?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Добавлена поддержка для DHCP формата файлов. --- pym/cl_profile.py | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/pym/cl_profile.py b/pym/cl_profile.py index b948902..9f51ab3 100644 --- a/pym/cl_profile.py +++ b/pym/cl_profile.py @@ -2876,7 +2876,7 @@ class profile(_file, _terms, xmlShare): dirObjsApply = [] for dirObj in dirObjs: dirInfoFile = os.path.join(dirObj.baseDir, self.profDirNameFile) - ret = self.__getApplyHeadDirRoot(dirInfoFile) + ret = self.__isApplyHeadDir(dirInfoFile) if ret: dirObjsApply.append(dirObj) else: @@ -3019,7 +3019,7 @@ class profile(_file, _terms, xmlShare): textProfile = FD.read() FD.close() except: - self.setError(_("Error open profile#: " ) +\ + self.setError(_("Error open profile: " ) +\ profileDirFile) return (applyDir, False) objHead = dirHeader(textProfile, self.objVar,function) @@ -3083,7 +3083,7 @@ class profile(_file, _terms, xmlShare): dirObjsApply = [] for dirObj in dirObjs: dirInfoFile = os.path.join(dirObj.baseDir, self.profDirNameFile) - ret = self.__getApplyHeadDirRoot(dirInfoFile) + ret = self.__isApplyHeadDir(dirInfoFile) if ret: dirObjsApply.append(dirObj) else: @@ -3172,7 +3172,7 @@ class profile(_file, _terms, xmlShare): return False return filesApply - def __getApplyHeadDirRoot(self, profileDirFile): + def __isApplyHeadDir(self, profileDirFile): """Будет ли применен профиль корневой директории Возвращает True, False @@ -3189,9 +3189,12 @@ class profile(_file, _terms, xmlShare): textProfile = FD.read() FD.close() except: - self.setError(_("Error open profile#: " ) +\ + self.setError(_("Error open profile: " ) +\ profileDirFile) return False + # Заменяем переменные на их значения + textProfile = self.applyVarsProfile(textProfile, profileDirFile) + # Обработка заголовка objHead = dirHeader(textProfile, self.objVar,function) if not objHead.headerCorrect: self.setError(_("Incorrect profile: " ) +\ @@ -3267,9 +3270,12 @@ class profile(_file, _terms, xmlShare): textProfile = FD.read() FD.close() except: - self.setError(_("Error open profile#: " ) +\ + self.setError(_("Error open profile: " ) +\ profileDirFile) return (applyDir, False) + # Заменяем переменные на их значения + textProfile = self.applyVarsProfile(textProfile, profileDirFile) + # Обработка заголовка objHead = dirHeader(textProfile, self.objVar,function) if not objHead.headerCorrect: self.setError(_("Incorrect profile: " ) +\ @@ -6210,4 +6216,25 @@ the same nodes at one level") except: self.setError(_("Can not join profile")) return False - return True \ No newline at end of file + return True + + +class dhcp(bind): + """Класс для обработки конфигурационного файла типа dhcp + + """ + _comment = "#" + configName = "dhcp" + configVersion = "0.1" + __openArea = "{" + __closeArea = "[ \t]*\}[ \t]*" + sepFields = ";" + reOpen = re.compile(__openArea) + reClose = re.compile(__closeArea) + reCloseArea = re.compile(__closeArea + "\s*\Z") + reComment = re.compile("^[ \t]*%s"%(_comment)) + reSepFields = re.compile(sepFields) + reSeparator = re.compile("[ \t]+") + + def __init__(self,text): + bind.__init__(self,text) \ No newline at end of file