[Zope-Checkins] CVS: Zope/lib/python/ZConfig - SchemaParser.py:1.1.2.12

Fred L. Drake, Jr. fred@zope.com
Tue, 26 Nov 2002 12:38:55 -0500


Update of /cvs-repository/Zope/lib/python/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv22607

Modified Files:
      Tag: chrism-install-branch
	SchemaParser.py 
Log Message:
Remove unused import.
Convert imports to Python Normal Form.
Added type filter to getChildSections(), to match
Config.Configuration.


=== Zope/lib/python/ZConfig/SchemaParser.py 1.1.2.11 => 1.1.2.12 ===
--- Zope/lib/python/ZConfig/SchemaParser.py:1.1.2.11	Mon Nov 25 03:42:24 2002
+++ Zope/lib/python/ZConfig/SchemaParser.py	Tue Nov 26 12:38:54 2002
@@ -20,19 +20,19 @@
 
 import types
 
+from Common import *
+from Config import Configuration
+from SchemaInterfaces import IConfigKey, IConfigSection, IConfigRoot,\
+     IConfigMultiKey, IConfigMultiSection
+
 SECTION_TYPE = 'section'
 KEY_TYPE = 'key'
 SCHEMA_TYPE = 'schema'
 
-from SchemaInterfaces import IConfigKey, IConfigSection, IConfigRoot,\
-     IConfigMultiKey, IConfigMultiSection
-from Common import *
-from Config import Configuration
-import os
-
 missing = []
 nodefault = []
 
+
 class SchemaParser:
 
     handler_names = [
@@ -70,7 +70,7 @@
         global XMLParseError
         from xml.parsers import expat
         XMLParseError = expat.ExpatError
-        parser=expat.ParserCreate(encoding, ' ')
+        parser = expat.ParserCreate(encoding, ' ')
         parser.returns_unicode = 0
         return parser
 
@@ -221,7 +221,7 @@
             self.doSchemaError(msg)
         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 klass.startswith('.'):
@@ -300,6 +300,7 @@
 class SchemaConfiguration(Configuration):
     resolved = missing
     value = missing
+
     def __init__(self, type, name, context, parent):
         self.type = type
         self.name = name
@@ -346,6 +347,7 @@
 
 class ConfigKey(SchemaConfiguration):
     __implements__ = IConfigKey
+
     def populate(self, value):
         if self.value is not missing:
             raise ConfigurationError, (
@@ -382,6 +384,7 @@
 
 class ConfigMultiKey(ConfigKey):
     __implements__ = IConfigMultiKey
+
     def populate(self, value):
         self.setValue(value)
 
@@ -412,6 +415,7 @@
 
 class ConfigSection(SchemaConfiguration):
     __implements__ = IConfigSection
+
     def __init__(self, type, name, context, parent):
         SchemaConfiguration.__init__(self, type, name, context, parent)
         self.delegate = None
@@ -553,11 +557,15 @@
             else:
                 return None
 
-    def getChildSections(self):
+    def getChildSections(self, type=None):
         l = []
-        for meta_type, type, name in self.subs:
+        if type:
+            type = type.lower()
+        for meta_type, secttype, name in self.subs:
             if meta_type == SECTION_TYPE:
-                l.append(self.getSub(meta_type, type, name))
+                if type and secttype != type:
+                    continue
+                l.append(self.getSub(meta_type, secttype, name))
         return l
 
     def getValue(self):
@@ -656,7 +664,7 @@
 
     def keys(self):
         raise NotImplementedError
-    
+
     def getSection(self, type, name=None):
         raise NotImplementedError