[Checkins] SVN: zExceptions/trunk/src/zExceptions/ PEP8 cleanup

Hanno Schlichting hannosch at hannosch.eu
Sat Jun 5 12:02:54 EDT 2010


Log message for revision 113147:
  PEP8 cleanup
  

Changed:
  U   zExceptions/trunk/src/zExceptions/ExceptionFormatter.py
  U   zExceptions/trunk/src/zExceptions/ITracebackSupplement.py
  U   zExceptions/trunk/src/zExceptions/__init__.py
  U   zExceptions/trunk/src/zExceptions/tests/testExceptionFormatter.py
  U   zExceptions/trunk/src/zExceptions/tests/test___init__.py
  U   zExceptions/trunk/src/zExceptions/tests/test_unauthorized.py

-=-
Modified: zExceptions/trunk/src/zExceptions/ExceptionFormatter.py
===================================================================
--- zExceptions/trunk/src/zExceptions/ExceptionFormatter.py	2010-06-05 15:56:05 UTC (rev 113146)
+++ zExceptions/trunk/src/zExceptions/ExceptionFormatter.py	2010-06-05 16:02:53 UTC (rev 113147)
@@ -18,7 +18,6 @@
 import sys
 import cgi
 
-
 DEBUG_EXCEPTION_FORMATTER = 1
 
 
@@ -114,7 +113,7 @@
         return None
 
     def formatTracebackInfo(self, tbi):
-        return self.formatSupplementLine('__traceback_info__: %s' % (tbi,))
+        return self.formatSupplementLine('__traceback_info__: %s' % (tbi, ))
 
     def formatLine(self, tb):
         f = tb.tb_frame
@@ -138,10 +137,10 @@
         result.append(self.escape(s))
 
         # Output a traceback supplement, if any.
-        if locals.has_key('__traceback_supplement__'):
+        if '__traceback_supplement__' in locals:
             # Use the supplement defined in the function.
             tbs = locals['__traceback_supplement__']
-        elif globals.has_key('__traceback_supplement__'):
+        elif '__traceback_supplement__' in globals:
             # Use the supplement defined in the module.
             # This is used by Scripts (Python).
             tbs = globals['__traceback_supplement__']
@@ -197,7 +196,6 @@
         return result
 
 
-
 class HTMLExceptionFormatter (TextExceptionFormatter):
 
     line_sep = '<br />\r\n'
@@ -232,7 +230,6 @@
         return None
 
 
-
 limit = 200
 
 if hasattr(sys, 'tracebacklimit'):

Modified: zExceptions/trunk/src/zExceptions/ITracebackSupplement.py
===================================================================
--- zExceptions/trunk/src/zExceptions/ITracebackSupplement.py	2010-06-05 15:56:05 UTC (rev 113146)
+++ zExceptions/trunk/src/zExceptions/ITracebackSupplement.py	2010-06-05 16:02:53 UTC (rev 113147)
@@ -14,10 +14,10 @@
 """ITracebackSupplement interface definition.
 """
 
-
 from zope.interface import Interface
 from zope.interface import Attribute
 
+
 class ITracebackSupplement(Interface):
     """Provides valuable information to supplement an exception traceback.
 
@@ -33,8 +33,7 @@
         Normally this generates a URL in the traceback that the user
         can visit to manage the object.  Set to None if unknown or
         not available.
-        """
-        )
+        """)
 
     object = Attribute(
         'object',
@@ -42,8 +41,7 @@
         occurred.
 
         Set to None if unknown or not available.
-        """
-        )
+        """)
 
     line = Attribute(
         'line',
@@ -51,8 +49,7 @@
         occurred.
 
         Set to 0 or None if the line number is unknown.
-        """
-        )
+        """)
 
     column = Attribute(
         'column',
@@ -60,16 +57,14 @@
         occurred.
 
         Set to None if the column number is unknown.
-        """
-        )
+        """)
 
     expression = Attribute(
         'expression',
         """Optional.  Set to the expression that was being evaluated.
 
         Set to None if not available or not applicable.
-        """
-        )
+        """)
 
     warnings = Attribute(
         'warnings',
@@ -77,10 +72,8 @@
 
         Set to None if not available, not applicable, or if the exception
         itself provides enough information.
-        """
-        )
+        """)
 
-
     def getInfo(as_html=0):
         """Optional.  Returns a string containing any other useful info.
 

Modified: zExceptions/trunk/src/zExceptions/__init__.py
===================================================================
--- zExceptions/trunk/src/zExceptions/__init__.py	2010-06-05 15:56:05 UTC (rev 113146)
+++ zExceptions/trunk/src/zExceptions/__init__.py	2010-06-05 16:02:53 UTC (rev 113147)
@@ -25,28 +25,35 @@
 from zope.security.interfaces import IForbidden
 from zExceptions.unauthorized import Unauthorized
 
+
 class BadRequest(Exception):
     implements(IException)
 
+
 class InternalError(Exception):
     implements(IException)
 
+
 class NotFound(Exception):
     implements(INotFound)
 
+
 class Forbidden(Exception):
     implements(IForbidden)
 
+
 class MethodNotAllowed(Exception):
     pass
 
+
 class Redirect(Exception):
     pass
 
+
 def convertExceptionType(name):
     import zExceptions
     etype = None
-    if __builtins__.has_key(name):
+    if name in __builtins__:
         etype = __builtins__[name]
     elif hasattr(zExceptions, name):
         etype = getattr(zExceptions, name)
@@ -55,6 +62,7 @@
         issubclass(etype, Exception)):
         return etype
 
+
 def upgradeException(t, v):
     # If a string exception is found, convert it to an equivalent
     # exception defined either in builtins or zExceptions. If none of

Modified: zExceptions/trunk/src/zExceptions/tests/testExceptionFormatter.py
===================================================================
--- zExceptions/trunk/src/zExceptions/tests/testExceptionFormatter.py	2010-06-05 15:56:05 UTC (rev 113146)
+++ zExceptions/trunk/src/zExceptions/tests/testExceptionFormatter.py	2010-06-05 16:02:53 UTC (rev 113147)
@@ -15,15 +15,9 @@
 ExceptionFormatter tests.
 """
 
-from unittest import TestCase, TestSuite, main, makeSuite
-
-try:
-    from Testing.CleanUp import CleanUp # Base class w registry cleanup
-except ImportError:
-    class CleanUp:
-        pass
-
 import sys
+from unittest import TestCase, TestSuite, makeSuite
+
 from zExceptions.ExceptionFormatter import format_exception
 
 
@@ -35,11 +29,10 @@
         del b
 
 
-class ExceptionForTesting (Exception):
+class ExceptionForTesting(Exception):
     pass
 
 
-
 class TestingTracebackSupplement:
 
     source_url = '/somepath'
@@ -51,9 +44,8 @@
         self.expression = expression
 
 
+class Test(TestCase):
 
-class Test(CleanUp, TestCase):
-
     def testBasicNamesText(self, as_html=0):
         try:
             raise ExceptionForTesting
@@ -129,8 +121,10 @@
             self.fail('no exception occurred')
 
     def testQuoteLastLine(self):
-        class C: pass
-        try: raise TypeError, C()
+        class C:
+            pass
+        try:
+            raise TypeError, C()
         except:
             s = tb(1)
         else:
@@ -139,11 +133,7 @@
         self.assert_(s.find('&gt;') >= 0, s)
 
 
-
 def test_suite():
     return TestSuite((
         makeSuite(Test),
         ))
-
-if __name__=='__main__':
-    main(defaultTest='test_suite')

Modified: zExceptions/trunk/src/zExceptions/tests/test___init__.py
===================================================================
--- zExceptions/trunk/src/zExceptions/tests/test___init__.py	2010-06-05 15:56:05 UTC (rev 113146)
+++ zExceptions/trunk/src/zExceptions/tests/test___init__.py	2010-06-05 16:02:53 UTC (rev 113147)
@@ -1,5 +1,6 @@
 import unittest
 
+
 class Test_convertExceptionType(unittest.TestCase):
 
     def _callFUT(self, name):
@@ -19,6 +20,7 @@
     def test_name_in_zExceptions_not_an_exception_returns_None(self):
         self.failUnless(self._callFUT('convertExceptionType') is None)
 
+
 class Test_upgradeException(unittest.TestCase):
 
     def _callFUT(self, t, v):
@@ -47,6 +49,7 @@
         self.assertEqual(t, InternalError)
         self.assertEqual(v, ('Nonesuch', 'TEST'))
 
+
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite(Test_convertExceptionType),

Modified: zExceptions/trunk/src/zExceptions/tests/test_unauthorized.py
===================================================================
--- zExceptions/trunk/src/zExceptions/tests/test_unauthorized.py	2010-06-05 15:56:05 UTC (rev 113146)
+++ zExceptions/trunk/src/zExceptions/tests/test_unauthorized.py	2010-06-05 16:02:53 UTC (rev 113147)
@@ -123,6 +123,3 @@
     suite = unittest.TestSuite()
     suite.addTest(unittest.makeSuite(UnauthorizedTests))
     return suite
-
-if __name__ == '__main__':
-    unittest.main(defaultTest='test_suite')



More information about the checkins mailing list