[Zope-Checkins] CVS: Packages/SFTPGateway/src/ZConfig - datatypes.py:1.21

Fred L. Drake, Jr. fred at zope.com
Thu Jan 1 01:12:43 EST 2004


Update of /cvs-repository/Packages/SFTPGateway/src/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv21013

Modified Files:
	datatypes.py 
Log Message:
better exception messages


=== Packages/SFTPGateway/src/ZConfig/datatypes.py 1.20 => 1.21 ===
--- Packages/SFTPGateway/src/ZConfig/datatypes.py:1.20	Wed Dec 31 20:58:48 2003
+++ Packages/SFTPGateway/src/ZConfig/datatypes.py	Thu Jan  1 01:12:42 2004
@@ -70,6 +70,8 @@
 
 
 class RegularExpressionConversion:
+    reason = "value did not match regular expression"
+
     def __init__(self, regex):
         self._rx = re.compile(regex)
 
@@ -78,8 +80,7 @@
         if m and m.group() == value:
             return value
         else:
-            raise ValueError("value did not match regular expression: "
-                             + `value`)
+            raise ValueError("%s: %s" % (self.reason, repr(value)))
 
 
 def check_locale(value):
@@ -119,17 +120,23 @@
 _ident_re = "[_a-zA-Z][_a-zA-Z0-9]*"
 
 class IdentifierConversion(ASCIIConversion):
+    reason = "not a valid Python identifier"
+
     def __init__(self):
         ASCIIConversion.__init__(self, _ident_re)
 
 
 class DottedNameConversion(ASCIIConversion):
+    reason = "not a valid dotted name"
+
     def __init__(self):
         ASCIIConversion.__init__(self,
                                  r"%s(?:\.%s)*" % (_ident_re, _ident_re))
 
 
 class DottedNameSuffixConversion(ASCIIConversion):
+    reason = "not a valid dotted name or suffix"
+
     def __init__(self):
         ASCIIConversion.__init__(self,
                                  r"(?:%s)(?:\.%s)*|(?:\.%s)+"




More information about the Zope-Checkins mailing list