[Zope-Checkins] CVS: Zope3/lib/python/Zope/Configuration - Action.py:1.1.2.3.14.1 ConfigurationDirectiveInterfaces.py:1.1.2.3.14.1 HookRegistry.py:1.1.2.2.10.1 metaConfigure.py:1.1.2.1.10.1 xmlconfig.py:1.1.2.15.8.1
Steve Alexander
steve@cat-box.net
Wed, 29 May 2002 11:18:16 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Configuration
In directory cvs.zope.org:/tmp/cvs-serv16524/lib/python/Zope/Configuration
Modified Files:
Tag: Zope3InWonderland-branch
Action.py ConfigurationDirectiveInterfaces.py HookRegistry.py
metaConfigure.py xmlconfig.py
Log Message:
standardisation of whitespace, breaking of lines >= 80 characters.
=== Zope3/lib/python/Zope/Configuration/Action.py 1.1.2.3 => 1.1.2.3.14.1 ===
"""
-def Action( discriminator, callable, args=(), kw={}):
+def Action(discriminator, callable, args=(), kw={}):
return discriminator, callable, args, kw
=== Zope3/lib/python/Zope/Configuration/ConfigurationDirectiveInterfaces.py 1.1.2.3 => 1.1.2.3.14.1 ===
- A discriminator, value used to identify conflicting
- actions. Actions cnflict of they have the same value values
+ actions. Actions conflict if they have the same values
for their discriminators.
- callable object
=== Zope3/lib/python/Zope/Configuration/HookRegistry.py 1.1.2.2 => 1.1.2.2.10.1 ===
raise DuplicationError(hname)
try:
- defaultimpl=name.resolve(hname)
+ defaultimpl = name.resolve(hname)
except ImportError:
- raise BadHookableError(
- "hookable %s cannot be found" % hname)
+ raise BadHookableError("hookable %s cannot be found" % hname)
parent, last=self._getParentAndLast(hname)
implfunc="%s_hook" % last
@@ -53,7 +52,7 @@
note it must be in the same module as the hookable""" %
implfunc)
- self._reg[hname]=0
+ self._reg[hname] = 0
def addHook(self, hookablename, hookname):
@@ -62,14 +61,15 @@
if self._reg[hookablename]:
raise DuplicateHookError(hookablename, hookname)
try:
- implementation=name.resolve(hookname)
+ implementation = name.resolve(hookname)
except ImportError:
raise BadHookError('cannot find implementation', hookname)
try:
hookableDefault=name.resolve(hookablename)
except:
raise BadHookableError(
- 'hookable cannot be found, but was found earlier: some code has probably masked the hookable',
+ 'hookable cannot be found, but was found earlier: '
+ 'some code has probably masked the hookable',
hookablename)
# This won't work as is: I'd have to create a NumberTypes and do
@@ -88,12 +88,12 @@
# find and import immediate parent
- parent, last=self._getParentAndLast(hookablename)
+ parent,last = self._getParentAndLast(hookablename)
# set parent.last to implementation
setattr(parent, "%s_hook" % last, implementation)
- self._reg[hookablename]=hookname
+ self._reg[hookablename] = hookname
def _getParentAndLast(self, hookablename):
if hookablename.endswith('.') or hookablename.endswith('+'):
@@ -101,25 +101,27 @@
repeat = 1
else:
repeat = 0
- names=hookablename.split(".")
- last=names.pop()
- importname=".".join(names)
+ names = hookablename.split(".")
+ last = names.pop()
+ importname = ".".join(names)
if not importname:
if not repeat:
raise BadHookableError(
- 'hookable cannot be on top level of Python namespace', hookablename)
- importname=last
- parent=__import__(importname,{},{},('__doc__',))
- child=getattr(parent, last, self)
+ 'hookable cannot be on top level of Python namespace',
+ hookablename)
+ importname = last
+ parent = __import__(importname, {}, {}, ('__doc__',))
+ child = getattr(parent, last, self)
if child is self:
raise BadHookableError(
- 'hookable cannot be on top level of Python namespace', hookablename)
+ 'hookable cannot be on top level of Python namespace',
+ hookablename)
while repeat:
- grand=getattr(child, last, self)
+ grand = getattr(child, last, self)
if grand is self:
break
- parent=child
- child=grand
+ parent = child
+ child = grand
if type(parent) is not ModuleType:
raise BadHookableError("parent of hookable must be a module")
@@ -127,10 +129,15 @@
return parent, last
def getHooked(self):
- return [(key, self._reg[key]) for key in self._reg if self._reg[key]]
+ return [(key, self._reg[key])
+ for key in self._reg
+ if self._reg[key]]
def getUnhooked(self):
- return [(key, self._reg[key]) for key in self._reg if not self._reg[key]]
+ return [(key, self._reg[key])
+ for key in self._reg
+ if not self._reg[key]]
def getHookables(self):
- return [(key, self._reg[key]) for key in self._reg]
\ No newline at end of file
+ return [(key, self._reg[key])
+ for key in self._reg]
=== Zope3/lib/python/Zope/Configuration/metaConfigure.py 1.1.2.1 => 1.1.2.1.10.1 ===
$Id$
"""
-
from Action import Action
from HookRegistry import HookRegistry
-hookRegistry=HookRegistry() # one could make this a service and
+# one could make hookRegistry a service and
# theoretically use it TTW, but that doesn't immediately seem like a
# great idea
+hookRegistry = HookRegistry()
-addHookable=hookRegistry.addHookable
-addHook=hookRegistry.addHook
+addHookable = hookRegistry.addHookable
+addHook = hookRegistry.addHook
def provideHookable(_context, name, module=None):
if module:
- name="%s.%s" % (module, name)
- name=_context.getNormalizedName(name)
+ name = "%s.%s" % (module, name)
+ name = _context.getNormalizedName(name)
return [
Action(
- discriminator = ('addHookable', name),
- callable = addHookable,
- args = (name,)
+ discriminator=('addHookable', name),
+ callable=addHookable,
+ args=(name,)
)
]
def provideHook(_context, name, implementation, module=None):
if module:
- name="%s.%s" % (module, name)
- name=_context.getNormalizedName(name)
- implementation=_context.getNormalizedName(implementation)
+ name = "%s.%s" % (module, name)
+ name = _context.getNormalizedName(name)
+ implementation = _context.getNormalizedName(implementation)
return [
Action(
- discriminator = ('addHook', name),
- callable = addHook,
- args = (name, implementation)
+ discriminator=('addHook', name),
+ callable=addHook,
+ args=(name, implementation)
)
]
=== Zope3/lib/python/Zope/Configuration/xmlconfig.py 1.1.2.15 => 1.1.2.15.8.1 ===
mess = "\n%s: %s" % (mess.__class__.__name__, mess)
except AttributeError:
- mess=str(mess)
- self.lno=locator.getLineNumber()
- self.cno=locator.getColumnNumber()
- self.sid=locator.getSystemId()
- self.mess=mess
+ mess = str(mess)
+ self.lno = locator.getLineNumber()
+ self.cno = locator.getColumnNumber()
+ self.sid = locator.getSystemId()
+ self.mess = mess
def __str__(self):
return "%s\nat line %s column %s of %s" % (
@@ -52,9 +52,9 @@
try:
mess = "%s: %s" % (mess.__class__.__name__, mess)
except AttributeError:
- mess=str(mess)
+ mess = str(mess)
self.lno, self.cno, self.sid = locator
- self.mess=mess
+ self.mess = mess
class ConfigurationHandler(ContentHandler):
@@ -68,10 +68,10 @@
context.resolve
def setDocumentLocator(self, locator):
- self.__locator=locator
+ self.__locator = locator
def startElementNS(self, name, qname, attrs):
- stack=self.__stack
+ stack = self.__stack
if not stack:
if name != self.__top_name:
raise ZopeXMLConfigurationError(
@@ -79,17 +79,18 @@
stack.append(None)
return
- kw={}
+ kw = {}
for (ns, aname), value in attrs.items():
if ns is None:
- aname=str(aname)
+ aname = str(aname)
if iskeyword(aname): aname += '_'
- kw[aname]=value
+ kw[aname] = value
if len(stack) == 1:
try:
- stack.append(begin(self.__directives, name, self.__context,
- **kw))
+ stack.append(
+ begin(self.__directives, name, self.__context, **kw)
+ )
except Exception, v:
__traceback_supplement__ = (
ConfigurationTracebackSupplement, self.__locator, v
@@ -139,9 +140,9 @@
"Zope XML Configuration error"
def __init__(self, l1, l2, des):
- self.l1=l1
- self.l2=l2
- self.des=des
+ self.l1 = l1
+ self.l2 = l2
+ self.des = des
def __str__(self):
return """Conflicting configuration action:
@@ -180,8 +181,9 @@
src = InputSource(getattr(file, 'name', '<string>'))
src.setByteStream(file)
parser = make_parser()
- parser.setContentHandler(ConfigurationHandler(actions, context,
- directives))
+ parser.setContentHandler(
+ ConfigurationHandler(actions, context,directives)
+ )
parser.setFeature(feature_namespaces, 1)
parser.parse(src)
@@ -190,7 +192,7 @@
for level, loc, des, callable, args, kw in call:
if des in descriptors:
raise ZopeConflictingConfigurationError(
- descriptors[des], loc, des)
+ descriptors[des], loc, des)
descriptors[des] = loc
callable(*args, **kw)
@@ -216,7 +218,7 @@
(self.include, {})}
f = open(file_name)
- self._stack=[file_name]
+ self._stack = [file_name]
xmlconfig(f, self._actions, Context(self._stack), self._directives)
f.close()