[Piglit] [PATCH v2 13/29] patterns.py: PEP8 compliance

Dylan Baker baker.dylan.c at gmail.com
Tue Jul 23 09:39:04 PDT 2013


There are four lines in a docstring that are not compliant, they are c++
code, and as such should not be wrapped.

Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
Reviewed-by: Chad Versace <chad.versace at linux.intel.com>
---
 framework/patterns.py | 53 +++++++++++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 25 deletions(-)

diff --git a/framework/patterns.py b/framework/patterns.py
index df2262a..751e1a7 100644
--- a/framework/patterns.py
+++ b/framework/patterns.py
@@ -23,37 +23,40 @@
 
 import threading
 
+
 class Singleton(object):
     '''
-            Modeled after http://www.python.org/download/releases/2.2.3/descrintro/*__new__
+    Modeled after
+    http://www.python.org/download/releases/2.2.3/descrintro/*__new__
 
-            A thread-safe (mostly -- see NOTE) Singleton class pattern.
+    A thread-safe (mostly -- see NOTE) Singleton class pattern.
 
-            NOTE: deleting a singleton instance (i.e. Singleton::delInstance) does not guarantee that something
-            else is currently using it. To reduce this risk, a program should not hold a reference to the
-            instance.  Rather, use the create/construct syntax (see example below) to access the instance.  Yet,
-            this still does not guarantee that this type of usage will result in a desired effect in a
-            multithreaded program.
-            You've been warned so use the singleton pattern wisely!
+    NOTE: deleting a singleton instance (i.e. Singleton::delInstance) does not
+    guarantee that something else is currently using it. To reduce this risk, a
+    program should not hold a reference to the instance.  Rather, use the
+    create/construct syntax (see example below) to access the instance.  Yet,
+    this still does not guarantee that this type of usage will result in a
+    desired effect in a multithreaded program.
+    You've been warned so use the singleton pattern wisely!
 
-            Example:
+    Example:
 
-            class MySingletonClass(Singleton):
-                    def init(self):
-                            print "in MySingletonClass::init()", self
+    class MySingletonClass(Singleton):
+            def init(self):
+                    print "in MySingletonClass::init()", self
 
-                    def foo(self):
-                            print "in MySingletonClass::foo()", self
+            def foo(self):
+                    print "in MySingletonClass::foo()", self
 
-            MySingletonClass().foo()
-            MySingletonClass().foo()
-            MySingletonClass().foo()
+    MySingletonClass().foo()
+    MySingletonClass().foo()
+    MySingletonClass().foo()
 
-            ---> output will look something like this:
-            in MySingletonClass::init() <__main__.MySingletonClass object at 0x7ff5b322f3d0>
-            in MySingletonClass::foo() <__main__.MySingletonClass object at 0x7ff5b322f3d0>
-            in MySingletonClass::foo() <__main__.MySingletonClass object at 0x7ff5b322f3d0>
-            in MySingletonClass::foo() <__main__.MySingletonClass object at 0x7ff5b322f3d0>
+    ---> output will look something like this:
+    in MySingletonClass::init() <__main__.MySingletonClass object at 0x7ff5b322f3d0>
+    in MySingletonClass::foo() <__main__.MySingletonClass object at 0x7ff5b322f3d0>
+    in MySingletonClass::foo() <__main__.MySingletonClass object at 0x7ff5b322f3d0>
+    in MySingletonClass::foo() <__main__.MySingletonClass object at 0x7ff5b322f3d0>
     '''
 
     lock = threading.RLock()
@@ -67,13 +70,13 @@ class Singleton(object):
             cls.__it__ = it = object.__new__(cls)
             it.init(*args, **kwargs)
             return it
-        finally: # this always gets called, even when returning from within the try block
+        finally:
             cls.lock.release()
 
     def init(self, *args, **kwargs):
         '''
-                Derived classes should override this method to do its initializations
-                The derived class should not implement a '__init__' method.
+        Derived classes should override this method to do its initializations
+        The derived class should not implement a '__init__' method.
         '''
         pass
 
-- 
1.8.3.1



More information about the Piglit mailing list