def show_class(class_name, cls, known_globals): base_names = [] for base in cls.__bases__: baseclass_fullname = str(base).split("'")[1] baseclass_name = baseclass_fullname.split('.')[-1] base_names.append(baseclass_name) print 'class %s(%s):' % (class_name, ', '.join(base_names)) print_doc_string(1, cls) # retrieve class attributes for name, value in get_data(cls): print_code_line(1, name + ' = ' + repr(value)) # retrieve methods for class_attr in inspect.classify_class_attrs(cls): #print '#', class_attr name, kind, owner_cls, attr = class_attr # a method may be inherited from a parent class # we want to only print methods defined in this # object. # also we only print methods. if owner_cls == cls and kind != 'data': show_function(name, attr, known_globals, indent=1) print # print class_name, name # if class_name.startswith('rs232') and name == 'reset': print
def show_function(func_name, func, known_globals, indent=0): f_args = inspect.getargspec(func) func_args = inspect.formatargspec(f_args.args, f_args.varargs, f_args.keywords, f_args.defaults) print_code_line(indent, 'def %s%s:' % (func_name, func_args)) print_doc_string(indent + 1, func) print_code(decompile_func_body(func.func_code, known_globals, indent + 1))
def show_function(func_name, func, known_globals, indent=0): f_args = inspect.getargspec(func) func_args = inspect.formatargspec(f_args.args, f_args.varargs, f_args.keywords, f_args.defaults) print_code_line(indent, 'def %s%s:' % (func_name, func_args)) print_doc_string(indent+1, func) print_code(decompile_func_body(func.func_code, known_globals, indent+1))