[Zope3-checkins] CVS: Zope3/src/zope/app/services/translation - filters.py:1.3

Fred L. Drake, Jr. fred@zope.com
Fri, 11 Apr 2003 13:54:34 -0400


Update of /cvs-repository/Zope3/src/zope/app/services/translation
In directory cvs.zope.org:/tmp/cvs-serv2448/app/services/translation

Modified Files:
	filters.py 
Log Message:
Kill off a few string-based exceptions.

=== Zope3/src/zope/app/services/translation/filters.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/services/translation/filters.py:1.2	Tue Mar 25 18:25:12 2003
+++ Zope3/src/zope/app/services/translation/filters.py	Fri Apr 11 13:54:03 2003
@@ -23,6 +23,16 @@
 from zope.app.interfaces.services.translation import ILocalTranslationService
 
 
+class ParseError(Exception):
+    def __init__(self, state, lineno):
+        Exception.__init__(self, state, lineno)
+        self.state = state
+        self.lineno = lineno
+
+    def __str__(self):
+        return "state %s, line %s" % (self.state, self.lineno)
+
+
 class GettextExportFilter:
 
     __implements__ =  IMessageExportFilter
@@ -155,7 +165,7 @@
             elif blank.match(line):
                 pointer = pointer + 1
             else:
-                raise 'ParseError', 'state 0, line %d\n' % (pointer + 1)
+                raise ParseError(0, pointer + 1)
         elif state == 1:
             if com.match(line):
                 COM.append(line.strip())
@@ -168,7 +178,7 @@
             elif blank.match(line):
                 pointer = pointer + 1
             else:
-                raise 'ParseError', 'state 1, line %d\n' % (pointer + 1)
+                raise ParseError(1, pointer + 1)
 
         elif state == 2:
             if com.match(line):
@@ -186,7 +196,7 @@
             elif blank.match(line):
                 pointer = pointer + 1
             else:
-                raise 'ParseError', 'state 2, line %d\n' % (pointer + 1)
+                raise ParseError(2, pointer + 1)
 
         elif state == 3:
             if com.match(line) or msgid.match(line):
@@ -200,7 +210,7 @@
             elif blank.match(line):
                 pointer = pointer + 1
             else:
-                raise 'ParseError', 'state 3, line %d\n' % (pointer + 1)
+                raise ParseError(3, pointer + 1)
 
     # the last also goes in
     if tuple(MSGID):