summaryrefslogtreecommitdiff
path: root/django/dispatch
diff options
context:
space:
mode:
authorLarry O'Neill <larryoneill@gmail.com>2013-10-14 20:13:14 +0100
committerTim Graham <timograham@gmail.com>2013-10-14 18:12:00 -0400
commit83b9bfea44e23c5770fa14a8921914839929233b (patch)
tree38039b835449a0dd8d0283286f7dbcf92ce5180a /django/dispatch
parent42a67ec1cd8cbaffd87f0a7b34714f7d4a259cfb (diff)
downloaddjango-83b9bfea44e23c5770fa14a8921914839929233b.tar.gz
Fixed #21266 -- Fixed E201,E202 pep8 warnings.
Diffstat (limited to 'django/dispatch')
-rw-r--r--django/dispatch/saferef.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/django/dispatch/saferef.py b/django/dispatch/saferef.py
index b816e71159..41756a1001 100644
--- a/django/dispatch/saferef.py
+++ b/django/dispatch/saferef.py
@@ -32,7 +32,7 @@ def safeRef(target, onDelete = None):
if callable(onDelete):
return weakref.ref(target, onDelete)
else:
- return weakref.ref( target )
+ return weakref.ref(target)
class BoundMethodWeakref(object):
"""'Safe' and reusable weak references to instance methods
@@ -70,7 +70,7 @@ class BoundMethodWeakref(object):
_allInstances = weakref.WeakValueDictionary()
- def __new__( cls, target, onDelete=None, *arguments,**named ):
+ def __new__(cls, target, onDelete=None, *arguments,**named):
"""Create new instance or return current instance
Basically this method of construction allows us to
@@ -85,12 +85,12 @@ class BoundMethodWeakref(object):
key = cls.calculateKey(target)
current =cls._allInstances.get(key)
if current is not None:
- current.deletionMethods.append( onDelete)
+ current.deletionMethods.append(onDelete)
return current
else:
- base = super( BoundMethodWeakref, cls).__new__( cls )
+ base = super(BoundMethodWeakref, cls).__new__(cls)
cls._allInstances[key] = base
- base.__init__( target, onDelete, *arguments,**named)
+ base.__init__(target, onDelete, *arguments,**named)
return base
def __init__(self, target, onDelete=None):
@@ -112,13 +112,13 @@ class BoundMethodWeakref(object):
methods = self.deletionMethods[:]
del self.deletionMethods[:]
try:
- del self.__class__._allInstances[ self.key ]
+ del self.__class__._allInstances[self.key]
except KeyError:
pass
for function in methods:
try:
- if callable( function ):
- function( self )
+ if callable(function):
+ function(self)
except Exception as e:
try:
traceback.print_exc()
@@ -127,20 +127,20 @@ class BoundMethodWeakref(object):
self, function, e)
)
self.deletionMethods = [onDelete]
- self.key = self.calculateKey( target )
+ self.key = self.calculateKey(target)
self.weakSelf = weakref.ref(target.__self__, remove)
self.weakFunc = weakref.ref(target.__func__, remove)
self.selfName = str(target.__self__)
self.funcName = str(target.__func__.__name__)
- def calculateKey( cls, target ):
+ def calculateKey(cls, target):
"""Calculate the reference key for this reference
Currently this is a two-tuple of the id()'s of the
target object and the target function respectively.
"""
return (id(target.__self__),id(target.__func__))
- calculateKey = classmethod( calculateKey )
+ calculateKey = classmethod(calculateKey)
def __str__(self):
"""Give a friendly representation of the object"""
@@ -155,7 +155,7 @@ class BoundMethodWeakref(object):
def __hash__(self):
return hash(self.key)
- def __bool__( self ):
+ def __bool__(self):
"""Whether we are still a valid reference"""
return self() is not None