From b2fbc7631de7a8f7de764a856e3106d1a37cfc37 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: Wed, 8 Sep 2010 16:50:21 +0400 Subject: [PATCH] Bugfix (error if only comment in /etc/calculate/calculate2.env) --- pym/cl_template.py | 17 +++++++++++++---- pym/format/plasma.py | 2 ++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pym/cl_template.py b/pym/cl_template.py index 3fdb512..859f4b5 100644 --- a/pym/cl_template.py +++ b/pym/cl_template.py @@ -4847,11 +4847,20 @@ class iniParser(_error, templateFormat): return True def isEmptyFile(self, textIni): - """Является ли файл пустым""" - if not textIni.strip(): - return True + """Если файл пустой или содержит только комментарии - False + + иначе - True + """ + if textIni.strip(): + if filter(lambda x: x.strip(), + map(lambda x:x[0].split(";")[0], + map(lambda x: x.split("#"), + textIni.splitlines()))): + return False + else: + return True else: - return False + return True def checkIniFile(self, textIni): """Проверка на правильность формата файла""" diff --git a/pym/format/plasma.py b/pym/format/plasma.py index d21c1d7..d43aed3 100644 --- a/pym/format/plasma.py +++ b/pym/format/plasma.py @@ -203,6 +203,8 @@ class plasma(samba): blTmp = self.blocTextObj.findBloc(self.text,self.reHeader,self.reBody) blocs = self.getFullAreas(blTmp) + if blocs == []: + return [] reH = re.compile("\[([^\[\]]+)\]") # Список имен блоков namesBlockList = []