[Zope3-checkins] CVS: Zope/lib/python/ZConfig - SchemaParser.py:1.1.2.17
Fred L. Drake, Jr.
fred@zope.com
Thu, 5 Dec 2002 22:29:39 -0500
Update of /cvs-repository/Zope/lib/python/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv25552
Modified Files:
Tag: chrism-install-branch
SchemaParser.py
Log Message:
Mostly a few simplifications.
=== Zope/lib/python/ZConfig/SchemaParser.py 1.1.2.16 => 1.1.2.17 ===
--- Zope/lib/python/ZConfig/SchemaParser.py:1.1.2.16 Thu Dec 5 15:13:57 2002
+++ Zope/lib/python/ZConfig/SchemaParser.py Thu Dec 5 22:29:37 2002
@@ -29,8 +29,8 @@
KEY_TYPE = 'key'
SCHEMA_TYPE = 'schema'
-missing = []
-nodefault = []
+missing = object()
+nodefault = object()
class SchemaParser(xml.sax.ContentHandler):
@@ -41,10 +41,10 @@
def __init__(self):
self._schema = None
+ self._seen_classes = {}
def __call__(self, f, context, print_classes=False):
self._stack = []
- self._seen_classes = {}
self._prefix = ''
self.context = context
self.print_classes = print_classes
@@ -118,8 +118,6 @@
if v is ConfigMissing:
l.append(k)
if l:
- self._seen_classes = {}
- del self._prefix
self.doSchemaError('Class loading failed for: %s' % ', '.join(l))
def getCurrentCdata(self):
@@ -138,7 +136,7 @@
def getClass(self, name):
if name.startswith('.'):
name = self._prefix + name
- if self._seen_classes.get(name, missing) is missing:
+ if self._seen_classes.get(name) is None:
try:
klass = importer(str(name))
except ImportError:
@@ -150,8 +148,8 @@
l = []
attrs = attrs.copy()
for name, default in expected:
- attr = attrs.get(name, missing)
- if attr is missing:
+ attr = attrs.get(name)
+ if attr is None:
if default is nodefault:
self.doSchemaError('must have nonempty "%s" attr' % name)
attr = default
@@ -171,8 +169,7 @@
expected = (('name', nodefault), ('class', nodefault), ('prefix', ''))
name, klass, prefix = self.doAttrs(expected, attrs)
self._prefix = prefix
- if self.print_classes and (self._seen_classes.get(klass, missing)
- is missing):
+ if self.print_classes and self._seen_classes.get(klass) is None:
if klass.startswith('.'):
printable_klass = klass[1:]
else:
@@ -205,8 +202,7 @@
expected = (('name', None), ('class', nodefault),)
name, klass = self.doAttrs(expected, attrs)
- if self.print_classes and (self._seen_classes.get(klass, missing)
- is missing):
+ if self.print_classes and self._seen_classes.get(klass) is None:
if klass.startswith('.'):
printable_klass = klass[1:]
else:
@@ -243,8 +239,7 @@
self.doSchemaError('Cannot nest sections within keys')
expected = (('type', nodefault), ('name', ''), ('class', nodefault))
type, name, klass = self.doAttrs(expected, attrs)
- if self.print_classes and (self._seen_classes.get(klass, missing)
- is missing):
+ if self.print_classes and self._seen_classes.get(klass) is None:
if klass.startswith('.'):
printable_klass = klass[1:]
else: