[Zope-Checkins] CVS: Zope3/lib/python/Zope/Configuration - name.py:1.1.2.9 xmlconfig.py:1.1.2.8
Martijn Pieters
mj@zope.com
Wed, 13 Feb 2002 00:03:37 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Configuration
In directory cvs.zope.org:/tmp/cvs-serv14206/Configuration
Modified Files:
Tag: Zope-3x-branch
name.py xmlconfig.py
Log Message:
Optimizations and code style updates:
- Use isinstance on type checks
- Test UnicodeType and StringType through StringTypes
- Remove use of the string module
- Use startswith and endswith instead of slices.
- Fix weird tests where isinstance suffices.
=== Zope3/lib/python/Zope/Configuration/name.py 1.1.2.8 => 1.1.2.9 ===
def resolve(name, _silly=('__doc__',), _globals={}):
- if name[:1]=='.':
+ if name.startswith('.'):
name='ZopeProducts'+name
- if name[-1:] == '.':
+ if name.endswith('.'):
name = name[:-1]
repeat = 1
else:
@@ -38,6 +38,6 @@
return __import__(name, _globals, _globals, _silly)
else:
- if not repeat or (type(a) is not ModuleType):
+ if not repeat or (not isinstance(a, ModuleType)):
return a
mod += '.' + last
=== Zope3/lib/python/Zope/Configuration/xmlconfig.py 1.1.2.7 => 1.1.2.8 ===
from keyword import iskeyword
import sys, os
+from types import StringType
class ZopeXMLConfigurationError(Exception):
"Zope XML Configuration error"
def __init__(self, locator, mess):
- if type(mess) is not type(''):
+ if not isinstance(mess, StringType):
try:
mess = "\n%s: %s" % (mess.__class__.__name__, mess)
except AttributeError:
@@ -45,7 +46,7 @@
"""
def __init__(self, locator, mess):
- if type(mess) is not type(''):
+ if isinstance(mess, StringType):
try:
mess = "%s: %s" % (mess.__class__.__name__, mess)
except AttributeError: