[Checkins] SVN: Products.GenericSetup/branches/upgrade-upgrade-api/Products/GenericSetup/ pyflakes & pep8
Jean-Francois Roche
jfroche at jfroche.be
Mon May 23 09:11:40 EDT 2011
Log message for revision 121774:
pyflakes & pep8
Changed:
U Products.GenericSetup/branches/upgrade-upgrade-api/Products/GenericSetup/components.py
U Products.GenericSetup/branches/upgrade-upgrade-api/Products/GenericSetup/metadata.py
U Products.GenericSetup/branches/upgrade-upgrade-api/Products/GenericSetup/zcml.py
-=-
Modified: Products.GenericSetup/branches/upgrade-upgrade-api/Products/GenericSetup/components.py
===================================================================
--- Products.GenericSetup/branches/upgrade-upgrade-api/Products/GenericSetup/components.py 2011-05-23 13:00:46 UTC (rev 121773)
+++ Products.GenericSetup/branches/upgrade-upgrade-api/Products/GenericSetup/components.py 2011-05-23 13:11:39 UTC (rev 121774)
@@ -169,7 +169,7 @@
provided = _resolveDottedName(provided)
name = unicode(str(child.getAttribute('name')))
- for_ = child.getAttribute('for') or child.getAttribute('for_') #BBB
+ for_ = child.getAttribute('for') or child.getAttribute('for_') # BBB
required = []
for interface in for_.split():
required.append(_resolveDottedName(interface))
@@ -197,8 +197,8 @@
handler = child.getAttribute('handler')
if handler:
- raise ValueError, "Can not specify both a factory and a " \
- "handler in a subscriber registration."
+ raise ValueError("Can not specify both a factory and a " \
+ "handler in a subscriber registration.")
factory = _resolveDottedName(factory)
@@ -208,7 +208,7 @@
provided = _resolveDottedName(provided)
- for_ = child.getAttribute('for') or child.getAttribute('for_') #BBB
+ for_ = child.getAttribute('for') or child.getAttribute('for_') # BBB
required = []
for interface in for_.split():
required.append(_resolveDottedName(interface))
@@ -237,16 +237,15 @@
factory = child.getAttribute('factory')
if factory:
- raise ValueError, "Can not specify both a factory and a " \
- "handler in a subscriber registration."
-
+ raise ValueError("Can not specify both a factory and a " \
+ "handler in a subscriber registration.")
if child.hasAttribute('provides'):
- raise ValueError, "Cannot use handler with provides " \
- "in a subscriber registration."
+ raise ValueError("Cannot use handler with provides " \
+ "in a subscriber registration.")
handler = _resolveDottedName(handler)
- for_ = child.getAttribute('for') or child.getAttribute('for_') #BBB
+ for_ = child.getAttribute('for') or child.getAttribute('for_') # BBB
required = []
for interface in for_.split():
@@ -300,10 +299,9 @@
continue
if component and factory:
- raise ValueError, "Can not specify both a factory and a " \
- "component in a utility registration."
+ raise ValueError("Can not specify both a factory and a " \
+ "component in a utility registration.")
-
obj_path = child.getAttribute('object')
if not component and not factory and obj_path is not None:
# Support for registering the site itself
@@ -327,11 +325,11 @@
elif component:
self.context.registerUtility(component, provided, name)
elif factory:
- current = [ utility for utility in current_utilities
- if utility.provided==provided and
- utility.name==name ]
+ current = [utility for utility in current_utilities
+ if utility.provided == provided and
+ utility.name == name]
- if current and getattr(current[0], "factory", None)==factory:
+ if current and getattr(current[0], "factory", None) == factory:
continue
obj = factory()
@@ -362,11 +360,11 @@
def _extractAdapters(self):
fragment = self._doc.createDocumentFragment()
- registrations = [ {'factory': _getDottedName(reg.factory),
+ registrations = [{'factory': _getDottedName(reg.factory),
'provided': _getDottedName(reg.provided),
'required': reg.required,
'name': reg.name}
- for reg in self.context.registeredAdapters() ]
+ for reg in self.context.registeredAdapters()]
registrations.sort(key=itemgetter('name'))
registrations.sort(key=itemgetter('provided'))
blacklist = self._constructBlacklist()
@@ -394,10 +392,10 @@
def _extractSubscriptionAdapters(self):
fragment = self._doc.createDocumentFragment()
- registrations = [ {'factory': _getDottedName(reg.factory),
+ registrations = [{'factory': _getDottedName(reg.factory),
'provided': _getDottedName(reg.provided),
'required': reg.required}
- for reg in self.context.registeredSubscriptionAdapters() ]
+ for reg in self.context.registeredSubscriptionAdapters()]
registrations.sort(key=itemgetter('factory'))
registrations.sort(key=itemgetter('provided'))
blacklist = self._constructBlacklist()
@@ -423,9 +421,9 @@
def _extractHandlers(self):
fragment = self._doc.createDocumentFragment()
- registrations = [ {'factory': _getDottedName(reg.factory),
+ registrations = [{'factory': _getDottedName(reg.factory),
'required': reg.required}
- for reg in self.context.registeredHandlers() ]
+ for reg in self.context.registeredHandlers()]
registrations.sort(key=itemgetter('factory'))
registrations.sort(key=itemgetter('required'))
@@ -446,11 +444,11 @@
def _extractUtilities(self):
fragment = self._doc.createDocumentFragment()
- registrations = [ {'component': reg.component,
- 'factory' : getattr(reg, 'factory', None),
+ registrations = [{'component': reg.component,
+ 'factory': getattr(reg, 'factory', None),
'provided': _getDottedName(reg.provided),
'name': reg.name}
- for reg in self.context.registeredUtilities() ]
+ for reg in self.context.registeredUtilities()]
registrations.sort(key=itemgetter('name'))
registrations.sort(key=itemgetter('provided'))
site = aq_base(self._getSite())
@@ -527,6 +525,7 @@
logger = context.getLogger('componentregistry')
logger.debug("Nothing to import")
+
def exportComponentRegistry(context):
"""Export local components.
"""
@@ -551,4 +550,3 @@
if body is not None:
context.writeDataFile('componentregistry.xml', body,
exporter.mime_type)
-
Modified: Products.GenericSetup/branches/upgrade-upgrade-api/Products/GenericSetup/metadata.py
===================================================================
--- Products.GenericSetup/branches/upgrade-upgrade-api/Products/GenericSetup/metadata.py 2011-05-23 13:00:46 UTC (rev 121773)
+++ Products.GenericSetup/branches/upgrade-upgrade-api/Products/GenericSetup/metadata.py 2011-05-23 13:11:39 UTC (rev 121774)
@@ -24,11 +24,12 @@
METADATA_XML = 'metadata.xml'
-class ProfileMetadata( ImportConfiguratorBase ):
+
+class ProfileMetadata(ImportConfiguratorBase):
""" Extracts profile metadata from metadata.xml file.
"""
- def __init__( self, path, encoding=None, product=None ):
+ def __init__(self, path, encoding=None, product=None):
# don't call the base class __init__ b/c we don't have (or need)
# a site
@@ -45,32 +46,30 @@
self._encoding = encoding
- def __call__( self ):
-
- full_path = os.path.join( self._path, METADATA_XML )
- if not os.path.exists( full_path ):
+ def __call__(self):
+ full_path = os.path.join(self._path, METADATA_XML)
+ if not os.path.exists(full_path):
return {}
- file = open( full_path, 'r' )
- return self.parseXML( file.read() )
+ file = open(full_path, 'r')
+ return self.parseXML(file.read())
- def _getImportMapping( self ):
-
+ def _getImportMapping(self):
return {
'metadata':
- {'description': { CONVERTER: self._convertToUnique },
- 'version': { CONVERTER: self._convertToUnique },
- 'dependencies': { CONVERTER: self._convertToUnique },
+ {'description': {CONVERTER: self._convertToUnique},
+ 'version': {CONVERTER: self._convertToUnique},
+ 'dependencies': {CONVERTER: self._convertToUnique},
},
'description':
- { '#text': { KEY: None, DEFAULT: '' },
+ {'#text': {KEY: None, DEFAULT: ''},
},
'version':
- { '#text': { KEY: None },
+ {'#text': {KEY: None},
},
'dependencies':
- {'dependency': { KEY: None, DEFAULT: () },},
+ {'dependency': {KEY: None, DEFAULT: ()}},
'dependency':
- { '#text': { KEY: None },
+ {'#text': {KEY: None},
},
}
Modified: Products.GenericSetup/branches/upgrade-upgrade-api/Products/GenericSetup/zcml.py
===================================================================
--- Products.GenericSetup/branches/upgrade-upgrade-api/Products/GenericSetup/zcml.py 2011-05-23 13:00:46 UTC (rev 121773)
+++ Products.GenericSetup/branches/upgrade-upgrade-api/Products/GenericSetup/zcml.py 2011-05-23 13:11:39 UTC (rev 121774)
@@ -26,6 +26,7 @@
#### genericsetup:registerProfile
+
class IRegisterProfileDirective(Interface):
"""Register profiles with the global registry.
@@ -112,7 +113,6 @@
required=True)
-
def exportStep(context, name, handler, title=None, description=None):
context.action(
@@ -193,6 +193,7 @@
from upgrade import _registerUpgradeStep
from upgrade import _registerNestedUpgradeStep
+
class IUpgradeStepsDirective(Interface):
"""
@@ -304,6 +305,7 @@
args=(step,),
)
+
def upgradeDepends(_context, title, profile, description, import_profile=None,
import_steps=[], source='*', destination='*',
run_deps=False, purge=False, checker=None, sortkey=0):
More information about the checkins
mailing list