[Checkins] SVN: z3c.metrics/trunk/ pep8 fixes and a few pyflakes fixes as well

Ross Patterson me at rpatterson.net
Mon Mar 29 16:02:30 EDT 2010


Log message for revision 110282:
  pep8 fixes and a few pyflakes fixes as well
  

Changed:
  U   z3c.metrics/trunk/setup.py
  U   z3c.metrics/trunk/z3c/metrics/bbb.py
  U   z3c.metrics/trunk/z3c/metrics/dispatch.py
  U   z3c.metrics/trunk/z3c/metrics/engine.py
  U   z3c.metrics/trunk/z3c/metrics/index.py
  U   z3c.metrics/trunk/z3c/metrics/interfaces.py
  U   z3c.metrics/trunk/z3c/metrics/meta.py
  U   z3c.metrics/trunk/z3c/metrics/metric.py
  U   z3c.metrics/trunk/z3c/metrics/scale.py
  U   z3c.metrics/trunk/z3c/metrics/subscription.py
  U   z3c.metrics/trunk/z3c/metrics/testing.py
  U   z3c.metrics/trunk/z3c/metrics/tests.py
  U   z3c.metrics/trunk/z3c/metrics/zope2/creator.py
  U   z3c.metrics/trunk/z3c/metrics/zope2/discussion.py
  U   z3c.metrics/trunk/z3c/metrics/zope2/index.py
  U   z3c.metrics/trunk/z3c/metrics/zope2/meta.py
  U   z3c.metrics/trunk/z3c/metrics/zope2/ofs.py
  U   z3c.metrics/trunk/z3c/metrics/zope2/scale.py
  U   z3c.metrics/trunk/z3c/metrics/zope2/teamspace.py
  U   z3c.metrics/trunk/z3c/metrics/zope2/testing.py
  U   z3c.metrics/trunk/z3c/metrics/zope2/tests.py

-=-
Modified: z3c.metrics/trunk/setup.py
===================================================================
--- z3c.metrics/trunk/setup.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/setup.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -9,7 +9,8 @@
       long_description=(
           open(os.path.join("z3c", "metrics", "README.txt")).read() +
           "\n" + open(os.path.join("docs", "HISTORY.txt")).read()),
-      # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers
+      # Get more strings from
+      # http://www.python.org/pypi?%3Aaction=list_classifiers
       classifiers=[
         "Programming Language :: Python",
         "Topic :: Software Development :: Libraries :: Python Modules",

Modified: z3c.metrics/trunk/z3c/metrics/bbb.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/bbb.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/bbb.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -1,4 +1,6 @@
 try:
     from zope.component import eventtesting
+    eventtesting  # pyflakes
 except ImportError:
     from zope.app.event.tests import placelesssetup as eventtesting
+    eventtesting  # pyflakes

Modified: z3c.metrics/trunk/z3c/metrics/dispatch.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/dispatch.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/dispatch.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -6,9 +6,11 @@
 
 from z3c.metrics import interfaces
 
+
 class IAncestors(interface.Interface):
     """Iterate over the ancestors of a contained object."""
 
+
 @component.adapter(container_ifaces.IContained)
 @interface.implementer(IAncestors)
 def getAncestors(contained):
@@ -17,6 +19,7 @@
         yield ancestor
         ancestor = ancestor.__parent__
 
+
 @component.adapter(container_ifaces.IContained,
                    interfaces.IChangeScoreEvent)
 def dispatchToAncestors(obj, event):
@@ -42,8 +45,9 @@
     for ancestor in new_ancestors + old_ancestors:
         for _ in component.subscribers(
             [obj, event, ancestor], None):
-            pass # Just make sure the handlers run
+            pass  # Just make sure the handlers run
 
+
 @component.adapter(container_ifaces.IContainer,
                    interfaces.IBuildScoreEvent,
                    container_ifaces.IContainer)
@@ -55,8 +59,9 @@
         for sub in subs.sublocations():
             for ignored in component.subscribers(
                 (sub, event, obj), None):
-                pass # They do work in the adapter fetch
+                pass  # They do work in the adapter fetch
 
+
 class CreatorLookup(object):
     interface.implements(interfaces.ICreatorLookup)
     component.adapts(interfaces.ICreated)
@@ -68,6 +73,7 @@
     def __call__(self, creator_id):
         return self.authentication.getPrincipal(creator_id)
 
+
 @component.adapter(interfaces.ICreated,
                    interfaces.IChangeScoreEvent)
 def dispatchToCreators(obj, event):
@@ -76,28 +82,32 @@
     for creator_id in interfaces.ICreated(obj).creators:
         for _ in component.subscribers(
             [obj, event, creator_lookup(creator_id)], None):
-            pass # Just make sure the handlers run
+            pass  # Just make sure the handlers run
 
+
 class ICreatedDispatchEvent(interface.Interface):
     """Dispatched to subloacations for matching on creators."""
 
     event = interface.Attribute('Event')
     creators = interface.Attribute('Creators')
 
+
 class CreatedDispatchEvent(object):
     interface.implements(ICreatedDispatchEvent)
 
     def __init__(self, creators):
         self.creators = creators
 
+
 @component.adapter(security_ifaces.IPrincipal,
                    interfaces.IBuildScoreEvent)
 def dispatchToSiteCreated(creator, event):
     dispatched = CreatedDispatchEvent(set([creator.id]))
     for _ in component.subscribers(
         [hooks.getSite(), event, dispatched], None):
-        pass # Just make sure the handlers run
+        pass  # Just make sure the handlers run
 
+
 @component.adapter(interfaces.ICreated,
                    interfaces.IBuildScoreEvent,
                    ICreatedDispatchEvent)
@@ -108,4 +118,4 @@
         interfaces.ICreated(obj).creators):
         for _ in component.subscribers(
             [obj, event, creator_lookup(creator_id)], None):
-            pass # Just make sure the handlers run
+            pass  # Just make sure the handlers run

Modified: z3c.metrics/trunk/z3c/metrics/engine.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/engine.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/engine.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -2,6 +2,7 @@
 
 from z3c.metrics import interfaces
 
+
 class Engine(object):
     interface.implements(interfaces.IEngine)
     component.adapts(interfaces.IMetric,
@@ -21,23 +22,24 @@
     def removeScore(self):
         self.index.removeScoreFor(self.context)
 
+
 class WeightedEngine(Engine):
     component.adapts(interfaces.IMetric,
                      interfaces.IWeightedSubscription,
                      interface.Interface)
-        
+
     def addValue(self, value):
         scaled = self.scale.fromValue(value)
-        weighted = self.subscription.weight*scaled
+        weighted = self.subscription.weight * scaled
         self.index.changeScoreFor(self.context, weighted)
-        
+
     def changeValue(self, previous, current):
         scaled = (self.scale.fromValue(current) -
                   self.scale.fromValue(previous))
-        weighted = self.subscription.weight*scaled
+        weighted = self.subscription.weight * scaled
         self.index.changeScoreFor(self.context, weighted)
-        
+
     def removeValue(self, value):
         scaled = self.scale.fromValue(value)
-        weighted = self.subscription.weight*scaled
+        weighted = self.subscription.weight * scaled
         self.index.changeScoreFor(self.context, -weighted)

Modified: z3c.metrics/trunk/z3c/metrics/index.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/index.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/index.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -7,9 +7,11 @@
 
 from z3c.metrics import interfaces, scale
 
+
 class ScoreError(Exception):
     pass
 
+
 class IndexesScoreEvent(objectevent.ObjectEvent):
     interface.implements(interfaces.IIndexesScoreEvent)
 
@@ -17,10 +19,12 @@
         self.object = obj
         self.indexes = indexes
 
+
 class BuildScoreEvent(IndexesScoreEvent):
     interface.implements(interfaces.IBuildScoreEvent,
                          interfaces.IAddValueEvent)
 
+
 class Index(persistent.Persistent):
     interface.implements(interfaces.IIndex)
 

Modified: z3c.metrics/trunk/z3c/metrics/interfaces.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/interfaces.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/interfaces.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -1,10 +1,12 @@
 from zope import interface, schema
+from zope.component import interfaces as component_ifaces
 from zope.configuration import fields
-from zope.app.event import interfaces as event_ifaces
 
+
 class IMetric(interface.Interface):
     """Defines what values are to be collected for an object."""
 
+
 class IAttributeMetric(IMetric):
     """Retrieves the metric value from an interface field."""
 
@@ -20,9 +22,11 @@
         title=u'The interface field name of the value',
         required=False, default=False)
 
+
 class ISelfMetric(IAttributeMetric):
     """Initializes the object score and uses attribute value."""
 
+
 class IIndex(interface.Interface):
 
     initial = interface.Attribute('Initial Score')
@@ -43,12 +47,10 @@
     def buildScoreFor(obj):
         """Build the score for the object from scratch"""
 
-    def changeScoreFor(obj, amount):
-        """Change the score for the object by the amount"""
-
     def removeScoreFor(obj):
         """Remove the score for the object from the index"""
 
+
 class IScale(interface.Interface):
     """Translates metric values into scaled values for storage in the
     index.  The scale is also responsible for normalizing raw scores
@@ -64,6 +66,7 @@
         """Normalize the raw score acording to the scale.  Some scales
         may make use of a query."""
 
+
 class ISubscription(interface.Interface):
     """Associates a metric with an index and any parameters needed by
     the engine that are specific to the combination of metric and
@@ -73,11 +76,13 @@
         """Return the index for this subscription.  Some subscriptions
         may accept a context argument for looking up the index."""
 
+
 class IWeightedSubscription(interface.Interface):
     """A subscription that multiplies metric values by the weight."""
 
     weight = schema.Float(title=u'Weight', required=False, default=1.0)
 
+
 class IUtilitySubscription(interface.Interface):
     """The subscribed index is looked up as a utility."""
 
@@ -85,11 +90,13 @@
         title=u'Index Utility Interface',
         required=False, default=IIndex)
 
+
 class IUtilityWeightedSubscription(IUtilitySubscription,
                                    IWeightedSubscription):
     """ZCML directive for subscribing a metric to an index with a
     weight."""
 
+
 class IEngine(interface.Interface):
     """Process a values returned by a metric and update the raw score
     in the index."""
@@ -100,7 +107,7 @@
 
     def initScore():
         """Initialize the score for the context to the index"""
-        
+
     def addValue(value):
         """Add the value to the score for the context in the index"""
 
@@ -115,19 +122,22 @@
     def removeScore():
         """Remove the score for the context from the index"""
 
-class IChangeScoreEvent(event_ifaces.IObjectEvent):
+
+class IChangeScoreEvent(component_ifaces.IObjectEvent):
     """Change an object's score.
 
     These events are used under normal operation for incrementally
     updating a score in response to normal events on the object.
     These events are dispatched "up" to the scored object."""
 
-class IIndexesScoreEvent(event_ifaces.IObjectEvent):
+
+class IIndexesScoreEvent(component_ifaces.IObjectEvent):
     """If indexes is not None, the metrics will only apply the score
     changes to the indexes listed."""
 
     indexes = interface.Attribute('Indexes')
 
+
 class IBuildScoreEvent(IIndexesScoreEvent):
     """Build an object's score.
 
@@ -136,29 +146,34 @@
     "down" from the scored object to the objects whose values
     contribute to the score."""
 
-class IAddValueEvent(event_ifaces.IObjectEvent):
+
+class IAddValueEvent(component_ifaces.IObjectEvent):
     """Add a value from the object's score.
 
     These events are handled by the metrics to add values to the
     object's score and are independent of the direction of dispatch."""
 
+
 class IInitScoreEvent(IAddValueEvent):
     """Initialize the object's score only when not building.
 
     These events are handled by the metrics to initialize the object's
     score and are independent of the direction of dispatch."""
 
-class IRemoveValueEvent(event_ifaces.IObjectEvent):
+
+class IRemoveValueEvent(component_ifaces.IObjectEvent):
     """Remove a value from the object's score.
 
     These events are handled by the metrics to remove values from the
     object's score and are independent of the direction of
     dispatch."""
 
+
 class ICreated(interface.Interface):
     """List the creators of an object."""
 
     creators = interface.Attribute('Creators')
 
+
 class ICreatorLookup(interface.Interface):
     """Lookup creators by id."""

Modified: z3c.metrics/trunk/z3c/metrics/meta.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/meta.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/meta.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -6,6 +6,7 @@
 
 default = object()
 
+
 class IMetric(interfaces.IMetric):
     """Defines what values are to be collected for an object."""
 
@@ -13,9 +14,11 @@
         title=u'Interfaces of the objects the metric applied to',
         required=True, value_type=fields.GlobalObject())
 
+
 class IAttributeMetric(IMetric, interfaces.IAttributeMetric):
     """Retrieves the metric value from an interface field."""
 
+
 class Metric(config.GroupingContextDecorator):
 
     add_interface = interfaces.IAddValueEvent
@@ -32,17 +35,18 @@
         other_ifaces = self.handler_adapts[1:]
         metaconfigure.subscriber(
             _context=self.context,
-            for_=[object_iface, self.add_interface]+other_ifaces,
+            for_=[object_iface, self.add_interface] + other_ifaces,
             handler=getattr(self.metric, self.add_handler))
         metaconfigure.subscriber(
             _context=self.context,
-            for_=[object_iface, self.remove_interface]+other_ifaces,
+            for_=[object_iface, self.remove_interface] + other_ifaces,
             handler=getattr(self.metric, self.remove_handler))
 
     @property
     def handler_adapts(self):
-        return [self.object_interface]+self.for_
+        return [self.object_interface] + self.for_
 
+
 class InitMetric(Metric):
 
     metric_factory = metric.InitMetric
@@ -50,12 +54,14 @@
     add_handler = 'initSelfScore'
     remove_handler = 'removeSelfScore'
 
+
 class SelfMetric(Metric):
 
     metric_factory = metric.SelfMetric
     add_handler = 'initSelfScore'
     remove_handler = 'removeSelfScore'
 
+
 class OtherMetric(Metric):
 
     metric_factory = metric.OtherMetric
@@ -64,8 +70,9 @@
 
     @property
     def handler_adapts(self):
-        return self.for_+[self.object_interface]
+        return self.for_ + [self.object_interface]
 
+
 def weighted(_context, utility_interface, weight=default):
     sub = subscription.UtilityWeightedSubscription(
         utility_interface=utility_interface)
@@ -76,13 +83,11 @@
     metaconfigure.subscriber(
         _context=_context, provides=provides,
         for_=[interfaces.IMetric, _context.object_interface,
-              interfaces.IChangeScoreEvent]+_context.for_,
+              interfaces.IChangeScoreEvent] + _context.for_,
         factory=sub.getChangeScoreEngine)
     provides, = interface.implementedBy(sub.getBuildScoreEngine)
     metaconfigure.subscriber(
         _context=_context, provides=provides,
         for_=[interfaces.IMetric, _context.object_interface,
-              interfaces.IIndexesScoreEvent]+_context.for_,
+              interfaces.IIndexesScoreEvent] + _context.for_,
         factory=sub.getBuildScoreEngine)
-    
-    

Modified: z3c.metrics/trunk/z3c/metrics/metric.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/metric.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/metric.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -2,6 +2,7 @@
 
 from z3c.metrics import interfaces
 
+
 class InitMetric(object):
     interface.implements(interfaces.IMetric)
 
@@ -19,6 +20,7 @@
             [self, obj, event], interfaces.IEngine):
             engine.removeScore()
 
+
 class AttributeMetric(object):
     interface.implements(interfaces.IAttributeMetric)
 
@@ -50,6 +52,7 @@
             value = value()
         return value
 
+
 class SelfMetric(InitMetric, AttributeMetric):
 
     @component.adapter(interface.Interface,
@@ -63,6 +66,7 @@
                 engine.initScore()
             engine.addValue(value)
 
+
 class OtherMetric(AttributeMetric):
 
     @component.adapter(interface.Interface,

Modified: z3c.metrics/trunk/z3c/metrics/scale.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/scale.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/scale.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -1,4 +1,6 @@
-import math, datetime, time
+import math
+import datetime
+import time
 
 from zope import interface
 from zope.cachedescriptors import property
@@ -8,6 +10,7 @@
 
 inf = 1e1000000
 
+
 class ExponentialScale(persistent.Persistent):
     interface.implements(interfaces.IScale)
 
@@ -34,19 +37,20 @@
         return quantity
 
     def fromValue(self, value):
-        return self.origin*self.scale_ratio**(
-            self._fromDelta(value-self.start)/float(self.scale_unit))
+        return self.origin * self.scale_ratio ** (
+            self._fromDelta(value - self.start) / float(self.scale_unit))
 
     def toValue(self, scaled):
         return self.start + self._toDelta(
-            math.log(scaled/float(self.origin),
-                     self.scale_ratio)*self.scale_unit)
+            math.log(scaled / float(self.origin),
+                     self.scale_ratio) * self.scale_unit)
 
     def normalize(self, raw, query=None):
         if query is None:
             query = self.default
-        return raw/float(self.fromValue(query))
+        return raw / float(self.fromValue(query))
 
+
 def getOrigin(min_unit, scale_unit, scale_ratio):
     """
     The scale ratio to the power of the proportion of the minimum
@@ -61,9 +65,10 @@
 
     scale_ratio**(min_unit/scale_unit)-1 == 1/origin
     """
-    return 1/(scale_ratio**(
-        min_unit/float(scale_unit))-1)
-    
+    return 1 / (scale_ratio ** (
+        min_unit / float(scale_unit)) - 1)
+
+
 def getRatio(scaled, scale_units, scale_unit, min_unit=None):
     """
     Return the ratio such that the number of units will result in
@@ -76,7 +81,7 @@
 
     scaled*(scale_ratio**(
         min_unit/scale_unit)-1) == scale_ratio**units
-    
+
     scale_ratio**(min_unit/scale_unit)-1 == scale_ratio**units/scaled
 
     ----------------------------
@@ -95,9 +100,10 @@
 
 epoch = datetime.datetime(*time.gmtime(0)[:3])
 one_day = datetime.timedelta(1)
-one_year = one_day*365
-seconds_per_day = 24*60*60
+one_year = one_day * 365
+seconds_per_day = 24 * 60 * 60
 
+
 class ExponentialDatetimeScale(ExponentialScale):
 
     def __init__(self, scale_unit=one_year, scale_ratio=2,
@@ -112,8 +118,8 @@
 
     def _fromDelta(self, delta):
         """Convert a time delta into a float of seconds"""
-        return (delta.days*seconds_per_day + delta.seconds +
-                delta.microseconds/float(1000000))
+        return (delta.days * seconds_per_day + delta.seconds +
+                delta.microseconds / float(1000000))
 
     def _toDelta(self, quantity):
         return datetime.timedelta(seconds=quantity)

Modified: z3c.metrics/trunk/z3c/metrics/subscription.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/subscription.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/subscription.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -6,23 +6,25 @@
 
 default = object()
 
+
 class Subscription(object):
 
     @component.adapter(interfaces.IMetric,
                        interface.Interface,
-                       interfaces.IChangeScoreEvent) 
+                       interfaces.IChangeScoreEvent)
     @interface.implementer(interfaces.IEngine)
     def getChangeScoreEngine(self, metric, context, event, *args):
         return self.engine_factory(metric, self, context)
 
     @component.adapter(interfaces.IMetric,
                        interface.Interface,
-                       interfaces.IIndexesScoreEvent) 
+                       interfaces.IIndexesScoreEvent)
     @interface.implementer(interfaces.IEngine)
     def getBuildScoreEngine(self, metric, context, event, *args):
         if self.getIndex(context) in event.indexes:
             return self.engine_factory(metric, self, context)
 
+
 class WeightedSubscription(Subscription):
     interface.implements(interfaces.IWeightedSubscription)
 
@@ -31,11 +33,13 @@
     weight = fieldproperty.FieldProperty(
         interfaces.IWeightedSubscription['weight'])
 
+
 class ILocalSubscription(interfaces.ISubscription):
     """The subscribed index is stored on an attribute."""
 
     index = interface.Attribute('Index')
 
+
 class LocalSubscription(persistent.Persistent):
     interface.implements(ILocalSubscription)
     component.adapts(interfaces.IIndex)
@@ -46,6 +50,7 @@
     def getIndex(self, context=None):
         return self.index
 
+
 class UtilitySubscription(object):
     interface.implements(interfaces.IUtilitySubscription,
                          interfaces.ISubscription)
@@ -61,10 +66,12 @@
         return component.getUtility(
             self.utility_interface, context=context)
 
+
 class UtilityWeightedSubscription(WeightedSubscription,
                                   UtilitySubscription):
     pass
 
+
 class LocalWeightedSubscription(WeightedSubscription,
                                 LocalSubscription):
     pass

Modified: z3c.metrics/trunk/z3c/metrics/testing.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/testing.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/testing.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -6,13 +6,22 @@
 
 from z3c.metrics import index, interfaces
 
+
 class IFooDocIndex(interfaces.IIndex): pass
+
+
 class IBarDocIndex(interfaces.IIndex): pass
+
+
 class ICreatorIndex(interfaces.IIndex): pass
 
+
 class IDocument(interface.Interface): pass
+
+
 class IDescendant(interface.Interface): pass
 
+
 def setUpRoot():
     root = folder.rootFolder()
     sm = site.LocalSiteManager(root)
@@ -20,6 +29,7 @@
     hooks.setSite(root)
     return root
 
+
 class Principal(contained.Contained):
     interface.implements(security_ifaces.IPrincipal)
 
@@ -27,33 +37,41 @@
     def id(self):
         return self.__name__
 
+
 class Authentication(folder.Folder):
     interface.implements(security_ifaces.IAuthentication)
 
     getPrincipal = folder.Folder.__getitem__
 
+
 class Index(index.Index):
 
     def _getKeyFor(self, obj):
         return id(obj)
 
+
 class FooDocIndex(Index):
     interface.implements(IFooDocIndex)
 
+
 class BarDocIndex(Index):
     interface.implements(IBarDocIndex)
 
+
 class CreatorIndex(Index):
     interface.implements(ICreatorIndex)
 
+
 class Created(folder.Folder):
     interface.implements(interfaces.ICreated)
 
     creators = ()
 
+
 class Document(Created):
     interface.implements(IDocument)
 
+
 class Descendant(Created):
     interface.implements(IDescendant)
 
@@ -62,6 +80,8 @@
         """Callable created field attribute"""
         def get(self):
             return lambda: self.__dict__['created']
+
         def set(self, value):
             self.__dict__['created'] = value
+
         return property(get, set)

Modified: z3c.metrics/trunk/z3c/metrics/tests.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/tests.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/tests.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -6,14 +6,17 @@
 import z3c.metrics
 from z3c.metrics import bbb
 
+
 def setUp(test):
     cleanup.setUp()
     bbb.eventtesting.PlacelessSetup().setUp()
     xmlconfig.file('testing.zcml', z3c.metrics)
 
+
 def tearDown(test):
     cleanup.tearDown()
 
+
 def test_suite():
     return doctest.DocFileSuite(
         'scale.txt',
@@ -25,9 +28,9 @@
         'README.txt',
         setUp=setUp, tearDown=tearDown,
         optionflags=(
-            doctest.REPORT_NDIFF|
-            #doctest.REPORT_ONLY_FIRST_FAILURE|
-            doctest.NORMALIZE_WHITESPACE|
+            doctest.REPORT_NDIFF |
+            #doctest.REPORT_ONLY_FIRST_FAILURE |
+            doctest.NORMALIZE_WHITESPACE |
             doctest.ELLIPSIS))
 
 if __name__ == '__main__':

Modified: z3c.metrics/trunk/z3c/metrics/zope2/creator.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/zope2/creator.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/zope2/creator.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -6,6 +6,7 @@
 
 from z3c.metrics import interfaces
 
+
 class CreatorLookup(object):
     interface.implements(interfaces.ICreatorLookup)
     component.adapts(cmf_ifaces.ICatalogableDublinCore)
@@ -17,6 +18,7 @@
     def __call__(self, creator_id):
         return self.portal_membership.getMemberById(creator_id)
 
+
 class Creators(object):
     interface.implements(interfaces.ICreated)
     component.adapts(cmf_ifaces.ICatalogableDublinCore)
@@ -27,5 +29,3 @@
     @property.Lazy
     def creators(self):
         return self.context.listCreators()
-
-    

Modified: z3c.metrics/trunk/z3c/metrics/zope2/discussion.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/zope2/discussion.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/zope2/discussion.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -11,14 +11,17 @@
 
 from z3c.metrics import interfaces
 
+
 class ReplyCreatedEvent(contained.ObjectAddedEvent):
     interface.implementsOnly(interfaces.IChangeScoreEvent,
                              interfaces.IAddValueEvent)
 
+
 class ReplyDeletedEvent(contained.ObjectRemovedEvent):
     interface.implementsOnly(interfaces.IChangeScoreEvent,
                              interfaces.IRemoveValueEvent)
-    
+
+
 def createReply(self, *args, **kw):
     reply_id = createReply.orig(
         self, *args, **kw)
@@ -27,7 +30,8 @@
         newName=reply_id))
     return reply_id
 createReply.orig = DiscussionItem.DiscussionItemContainer.createReply
-    
+
+
 def deleteReply(self, reply_id, *args, **kw):
     reply = self.getReply(reply_id)
     reply_id = deleteReply.orig(self, reply_id, *args, **kw)
@@ -36,10 +40,12 @@
     return reply_id
 deleteReply.orig = DiscussionItem.DiscussionItemContainer.deleteReply
 
+
 def patch():
     DiscussionItem.DiscussionItemContainer.createReply = createReply
     DiscussionItem.DiscussionItemContainer.deleteReply = deleteReply
 
+
 def unpatch():
     DiscussionItem.DiscussionItemContainer.createReply = (
         createReply.orig)
@@ -49,6 +55,7 @@
 patch()
 cleanup.addCleanUp(unpatch)
 
+
 @component.adapter(cmf_ifaces.IDiscussionResponse,
                    interfaces.IChangeScoreEvent)
 def dispatchToDiscussed(obj, event):
@@ -58,8 +65,9 @@
     discussed = Acquisition.aq_parent(Acquisition.aq_inner(parent))
     for _ in component.subscribers(
         [obj, event, discussed], None):
-        pass # Just make sure the handlers run
+        pass  # Just make sure the handlers run
 
+
 @component.adapter(cmf_ifaces.IDiscussable,
                    interfaces.IBuildScoreEvent)
 def dispatchToReplies(obj, event, dispatched=None):
@@ -71,5 +79,4 @@
     for reply in portal_discussion.getDiscussionFor(obj).getReplies():
         for _ in component.subscribers(
             [reply, event, dispatched], None):
-            pass # Just make sure the handlers run
-    
+            pass  # Just make sure the handlers run

Modified: z3c.metrics/trunk/z3c/metrics/zope2/index.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/zope2/index.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/zope2/index.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -13,26 +13,32 @@
 from z3c.metrics import interfaces, index
 from z3c.metrics.zope2 import scale
 
+
 class IRemoveScoreEvent(interfaces.IRemoveValueEvent):
     """Remove the object score from the index."""
 
+
 class IAddSelfValueEvent(interfaces.IAddValueEvent):
     """Add self value with special handling for the index."""
     # This is necessary because for the OFS/CMF/ZCatalog mess we need
     # the self add handlers to trigger for initial indexing and
     # rebuilding scores but not on object add
 
+
 class InitIndexScoreEvent(index.IndexesScoreEvent):
     interface.implements(interfaces.IInitScoreEvent,
                          IAddSelfValueEvent)
 
+
 class RemoveIndexScoreEvent(index.IndexesScoreEvent):
     interface.implements(IRemoveScoreEvent)
 
+
 class IMetricsIndex(interfaces.IIndex,
                     plugidx_ifaces.IPluggableIndex):
     """sro"""
 
+
 class MetricsIndex(index.Index, SimpleItem.SimpleItem):
     """A Metrics Index in a ZCatalog"""
     interface.implements(IMetricsIndex)
@@ -103,6 +109,7 @@
         event = RemoveIndexScoreEvent(obj, [self])
         component.subscribers([obj, event], None)
 
+
 class MetricsIndexNodeAdapter(exportimport.PluggableIndexNodeAdapter):
     component.adapts(IMetricsIndex, gs_ifaces.ISetupEnviron)
 

Modified: z3c.metrics/trunk/z3c/metrics/zope2/meta.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/zope2/meta.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/zope2/meta.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -1,17 +1,20 @@
 from z3c.metrics import meta
 from z3c.metrics.zope2 import index, ofs
 
+
 class InitMetric(meta.InitMetric):
 
     metric_factory = ofs.InitMetric
     remove_interface = index.IRemoveScoreEvent
 
+
 class SelfMetric(meta.SelfMetric):
 
     metric_factory = ofs.SelfMetric
     add_interface = index.IAddSelfValueEvent
     remove_interface = index.IRemoveScoreEvent
 
+
 class OtherMetric(meta.OtherMetric):
 
     metric_factory = ofs.OtherMetric

Modified: z3c.metrics/trunk/z3c/metrics/zope2/ofs.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/zope2/ofs.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/zope2/ofs.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -5,6 +5,7 @@
 
 from z3c.metrics import interfaces, metric, dispatch
 
+
 @component.adapter(ofs_ifaces.IItem)
 @interface.implementer(dispatch.IAncestors)
 def getAncestors(contained):
@@ -14,6 +15,7 @@
         ancestor = Acquisition.aq_parent(
             Acquisition.aq_inner(ancestor))
 
+
 class InitMetric(metric.InitMetric):
 
     @component.adapter(interface.Interface,
@@ -22,9 +24,11 @@
         if not ofs_ifaces.IObjectWillBeAddedEvent.providedBy(event):
             super(InitMetric, self).removeSelfScore(obj, event)
 
+
 class SelfMetric(InitMetric, metric.SelfMetric):
     pass
 
+
 class OtherMetric(metric.OtherMetric):
 
     @component.adapter(interface.Interface,
@@ -34,4 +38,3 @@
         if not ofs_ifaces.IObjectWillBeAddedEvent.providedBy(event):
             super(OtherMetric, self).removeOtherValue(
                 other, event, obj)
-

Modified: z3c.metrics/trunk/z3c/metrics/zope2/scale.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/zope2/scale.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/zope2/scale.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -7,6 +7,7 @@
 epoch = DateTime.DateTime(0)
 one_year = 365
 
+
 class ExponentialDateTimeScale(scale.ExponentialDatetimeScale):
 
     def __init__(self, scale_unit=one_year, scale_ratio=2,

Modified: z3c.metrics/trunk/z3c/metrics/zope2/teamspace.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/zope2/teamspace.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/zope2/teamspace.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -9,14 +9,16 @@
 
 from z3c.metrics import interfaces
 
+
 @component.adapter(membership_ifaces.ITeamMembership,
                    interfaces.IChangeScoreEvent)
 def dispatchToSpaces(membership, event):
     for space in membership.getTeam().getTeamSpaces():
         for _ in component.subscribers(
             [membership, event, space], None):
-            pass # Just make sure the handlers run
+            pass  # Just make sure the handlers run
 
+
 @component.adapter(space_ifaces.ISpace,
                    interfaces.IBuildScoreEvent)
 def dispatchToTeamMemberships(space, event):
@@ -24,15 +26,17 @@
         for membership in team.getMemberships():
             for _ in component.subscribers(
                 [membership, event, space], None):
-                pass # Just make sure the handlers run
+                pass  # Just make sure the handlers run
 
+
 @component.adapter(membership_ifaces.ITeamMembership,
                    interfaces.IChangeScoreEvent)
 def dispatchToMember(membership, event):
     for _ in component.subscribers(
         [membership, event, membership.getMember()], None):
-        pass # Just make sure the handlers run
-    
+        pass  # Just make sure the handlers run
+
+
 @component.adapter(remember_ifaces.IReMember,
                    interfaces.IBuildScoreEvent)
 def dispatchToMemberMemberships(member, event):
@@ -41,4 +45,4 @@
         member.getId()):
         for _ in component.subscribers(
             [membership, event, member], None):
-            pass # Just make sure the handlers run
+            pass  # Just make sure the handlers run

Modified: z3c.metrics/trunk/z3c/metrics/zope2/testing.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/zope2/testing.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/zope2/testing.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -2,6 +2,7 @@
 
 import DateTime
 
+
 def freezeATDefaultDate(datetime_, cls, field_name='creation_date'):
     field = cls.schema[field_name]
 
@@ -9,6 +10,7 @@
     # original default method around to restore on cleanup
     if not hasattr(field, 'default_method_orig'):
         field.default_method_orig = field.default_method
+
         def cleanUp():
             field.default_method = field.default_method_orig
             del field.default_method_orig
@@ -16,11 +18,13 @@
 
     field.default_method = lambda: datetime_
 
+
 def freezeATDefaultDates(datetime_, classes,
                          field_name='creation_date'):
     for cls in classes:
         freezeATDefaultDate(datetime_, cls, field_name)
 
+
 class FrozenDateTime(DateTime.DateTime):
 
     def __init__(self, *args, **kw):
@@ -28,6 +32,7 @@
             return DateTime.DateTime.__init__(self, self._frozen)
         return DateTime.DateTime.__init__(self, *args, **kw)
 
+
 def freezeDateTime(datetime_, module):
     def cleanUp():
         if hasattr(module.DateTime, 'orig'):

Modified: z3c.metrics/trunk/z3c/metrics/zope2/tests.py
===================================================================
--- z3c.metrics/trunk/z3c/metrics/zope2/tests.py	2010-03-29 17:50:40 UTC (rev 110281)
+++ z3c.metrics/trunk/z3c/metrics/zope2/tests.py	2010-03-29 20:02:29 UTC (rev 110282)
@@ -7,21 +7,24 @@
 
 import z3c.metrics.zope2
 
+
 def setUp(test):
     cleanup.setUp()
     xmlconfig.file('testing.zcml', z3c.metrics.zope2)
 
+
 def tearDown(test):
     cleanup.tearDown()
 
+
 def test_suite():
     return ZopeTestCase.ZopeDocFileSuite(
         'catalog.txt',
         setUp=setUp, tearDown=tearDown,
         optionflags=(
-            doctest.REPORT_NDIFF|
-            #doctest.REPORT_ONLY_FIRST_FAILURE|
-            doctest.NORMALIZE_WHITESPACE|
+            doctest.REPORT_NDIFF |
+            #doctest.REPORT_ONLY_FIRST_FAILURE |
+            doctest.NORMALIZE_WHITESPACE |
             doctest.ELLIPSIS))
 
 if __name__ == '__main__':



More information about the checkins mailing list