[Zope3-checkins] CVS: Zope3/src/zope/configuration - xmlconfig.py:1.5
Barry Warsaw
barry@wooz.org
Thu, 2 Jan 2003 11:52:40 -0500
Update of /cvs-repository/Zope3/src/zope/configuration
In directory cvs.zope.org:/tmp/cvs-serv13035
Modified Files:
xmlconfig.py
Log Message:
Code cleanups, remove redundant imports, bumped the copyright years
=== Zope3/src/zope/configuration/xmlconfig.py 1.4 => 1.5 ===
--- Zope3/src/zope/configuration/xmlconfig.py:1.4 Fri Dec 27 19:02:29 2002
+++ Zope3/src/zope/configuration/xmlconfig.py Thu Jan 2 11:52:38 2003
@@ -1,6 +1,6 @@
##############################################################################
#
-# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# Copyright (c) 2001, 2002, 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -12,20 +12,20 @@
#
##############################################################################
"""
-
$Id$
"""
import os
-from zope.configuration import name
+import sys
+from keyword import iskeyword
+from types import StringType
from os.path import abspath
+
from xml.sax import make_parser
from xml.sax.xmlreader import InputSource
from xml.sax.handler import ContentHandler, feature_namespaces
+from zope.configuration import name
from zope.configuration.meta import begin, sub, end
-from keyword import iskeyword
-import sys, os
-from types import StringType
from zope.configuration.exceptions import ConfigurationError
# marker used in Context class and XMLConfig class to indicate
@@ -33,8 +33,9 @@
# when included, and the same went for all of its parents.
_NO_MODULE_GIVEN = object()
+
class ZopeXMLConfigurationError(ConfigurationError):
- "Zope XML Configuration error"
+ """Zope XML Configuration error"""
def __init__(self, locator, mess, etype=None):
if etype is None:
@@ -55,6 +56,7 @@
return 'File "%s", line %s, column %s\n\t%s' % (
self.sid, self.lno, self.cno, self.mess)
+
class ConfigurationExecutionError(ZopeXMLConfigurationError):
"""An error occurred during execution of a configuration action
"""
@@ -72,6 +74,7 @@
self.lno, self.cno, self.sid = locator
self.mess = mess
+
class ConfigurationHandler(ContentHandler):
__top_name = 'zopeConfigure'
@@ -104,7 +107,6 @@
if ns is None:
self.__context.file_attr(aname, value)
-
stack.append(None)
return
@@ -166,6 +168,7 @@
print 'endElementNS', actions
raise
+
class ZopeConflictingConfigurationError(ZopeXMLConfigurationError):
"Zope XML Configuration error"
@@ -184,6 +187,7 @@
self.l2[2], self.l2[0], self.l2[1],
)
+
class Context:
def __init__(self, stack, module):
self.__stackcopy = tuple(stack)
@@ -218,8 +222,8 @@
def package(self):
return self.__package
-def xmlconfig(file, actions=None, context=None, directives=None,
- testing=0):
+
+def xmlconfig(file, actions=None, context=None, directives=None, testing=0):
if context is None:
context = name
@@ -249,6 +253,7 @@
callable(*args, **kw)
+
def testxmlconfig(file, actions=None, context=None, directives=None):
"""xmlconfig that doesn't raise configuration errors
@@ -256,6 +261,7 @@
"""
return xmlconfig(file, actions, context, directives, testing=1)
+
class ZopeConfigurationConflictError(ZopeXMLConfigurationError):
def __init__(self, conflicts):
@@ -279,7 +285,6 @@
module_dir = abspath(os.path.split(module.__file__)[0])
file_name = os.path.join(module_dir, file_name)
-
self._actions = []
self._directives = {('*', 'include'):
(self.include, {})}
@@ -334,7 +339,6 @@
return ()
def _include(self, file_name, package):
-
f = open(file_name)
self._stack.append(file_name)
xmlconfig(f, self._actions, Context(self._stack, package),
@@ -345,7 +349,8 @@
def __call__(self):
self.organize()
- def __iter__(self): return iter(self._actions)
+ def __iter__(self):
+ return iter(self._actions)
def organize(self):
actions = self._actions