Revive pep8 and clean up the code

autopep8 is pretty cool :)
This commit is contained in:
Cole Robinson
2013-04-13 14:34:52 -04:00
parent fcc680cae1
commit 0d243983d0
158 changed files with 1469 additions and 790 deletions

View File

@@ -31,6 +31,7 @@ from types import FunctionType
from types import ClassType
from types import MethodType
def generate_wrapper(origfunc, name, do_tb):
def newfunc(*args, **kwargs):
tb = do_tb and ("\n%s" % "".join(traceback.format_stack())) or ""
@@ -40,6 +41,7 @@ def generate_wrapper(origfunc, name, do_tb):
return newfunc
def wrap_func(module, funcobj, tb):
name = funcobj.__name__
logging.debug("wrapfunc %s %s", funcobj, name)
@@ -47,6 +49,7 @@ def wrap_func(module, funcobj, tb):
newfunc = generate_wrapper(funcobj, name, tb)
setattr(module, name, newfunc)
def wrap_method(classobj, methodobj, tb):
name = methodobj.__name__
fullname = classobj.__name__ + "." + name
@@ -55,6 +58,7 @@ def wrap_method(classobj, methodobj, tb):
newfunc = generate_wrapper(methodobj, fullname, tb)
setattr(classobj, name, newfunc)
def wrap_class(classobj, tb):
logging.debug("wrapclas %s %s", classobj, classobj.__name__)
@@ -63,6 +67,7 @@ def wrap_class(classobj, tb):
if type(obj) is MethodType:
wrap_method(classobj, obj, tb)
def wrap_module(module, regex=None, tb=False):
for name in dir(module):
if regex and not re.match(regex, name):