[Zope-CVS] CVS: Packages/zpkgtools/zpkgtools - cfgparser.py:1.7

Fred L. Drake, Jr. fred at zope.com
Tue May 11 15:19:27 EDT 2004


Update of /cvs-repository/Packages/zpkgtools/zpkgtools
In directory cvs.zope.org:/tmp/cvs-serv8825

Modified Files:
	cfgparser.py 
Log Message:
be more careful when ConfigurationError is raised; only the parser is
responsible for knowing the URL and current line number


=== Packages/zpkgtools/zpkgtools/cfgparser.py 1.6 => 1.7 ===
--- Packages/zpkgtools/zpkgtools/cfgparser.py:1.6	Wed May  5 16:34:22 2004
+++ Packages/zpkgtools/zpkgtools/cfgparser.py	Tue May 11 15:19:18 2004
@@ -199,7 +199,12 @@
     def load(self):
         section = self.schema.getConfiguration()
         self.parse(section)
-        return self.schema.finishSection(section)
+        try:
+            return self.schema.finishSection(section)
+        except ConfigurationError, e:
+            e.lineno = self.lineno
+            e.url = self.url
+            raise
 
     def parse(self, section):
         done, line = self.nextline()
@@ -252,9 +257,19 @@
         # if name:
         #    name = name.lower()
         #
-        newsect = self.schema.startSection(section, type, name)
+        try:
+            newsect = self.schema.startSection(section, type, name)
+        except ConfigurationError, e:
+            e.lineno = self.lineno
+            e.url = self.url
+            raise
         if isempty:
-            self.schema.endSection(section, type, name, newsect)
+            try:
+                self.schema.endSection(section, type, name, newsect)
+            except ConfigurationError, e:
+                e.lineno = self.lineno
+                e.url = self.url
+                raise
             return section
         else:
             self.stack.append((type, name, section))
@@ -267,7 +282,12 @@
         opentype, name, prevsection = self.stack.pop()
         if type != opentype:
             self.error("unbalanced section end")
-        self.schema.endSection(prevsection, type, name, section)
+        try:
+            self.schema.endSection(prevsection, type, name, section)
+        except ConfigurationError, e:
+            e.lineno = self.lineno
+            e.url = self.url
+            raise
         return prevsection
 
     def handle_key_value(self, section, rest):
@@ -283,6 +303,7 @@
             self.schema.addValue(section, key, value)
         except ConfigurationError, e:
             e.lineno = self.lineno
+            e.url = self.url
             raise
 
     def replace(self, text):




More information about the Zope-CVS mailing list