mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Revive pep8 and clean up the code
autopep8 is pretty cool :)
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user