update
This commit is contained in:
parent
eb7f717a5a
commit
875ecc2c28
@ -25,38 +25,36 @@ def f_type(sub):
|
|||||||
if not attr_name.startswith('__') and not attr_name.startswith('builtin_function_or_method'):
|
if not attr_name.startswith('__') and not attr_name.startswith('builtin_function_or_method'):
|
||||||
return type(attr).__name__
|
return type(attr).__name__
|
||||||
|
|
||||||
|
#输出代码缩进级别
|
||||||
|
def print_with_indent(indent_level):
|
||||||
|
indent = " " * indent_level
|
||||||
|
return indent
|
||||||
|
|
||||||
|
def print_with(cls_name,head_str,indent_level):
|
||||||
|
if not cls_name.startswith('__') and not cls_name.startswith('_'):
|
||||||
|
lw.WriteLine(f"{print_with_indent(indent_level)}{head_str}:{cls_name}")
|
||||||
def main():
|
def main():
|
||||||
for module in modules:
|
for module in modules:
|
||||||
lw.WriteLine(f"-------------module name: {module.__name__}-------------")
|
lw.WriteLine(f"module name:{module.__name__}")
|
||||||
classes = inspect.getmembers(module)
|
classes = inspect.getmembers(module)
|
||||||
for cls_name,cls in classes:
|
for cls_name,cls in classes:
|
||||||
# 过滤掉以双下划线开头的成员
|
print_with(cls_name,"class",1)
|
||||||
if not cls_name.startswith('__') and not cls_name.startswith('_'):
|
subs = inspect.getmembers(cls)
|
||||||
lw.WriteLine(f"class: {module.__name__}.{cls_name}")
|
for sub_name,sub in subs:
|
||||||
# 获取类的所有成员
|
if inspect.isclass(sub):
|
||||||
subs = inspect.getmembers(cls,inspect.isclass)
|
print_with(sub_name,"class",2)
|
||||||
for sub_name, sub in subs:
|
attrs=inspect.getmembers(sub)
|
||||||
if not sub_name.startswith('__'):
|
for attr_name,attr in attrs:
|
||||||
lw.WriteLine(f" types:{sub_name}")
|
if attr_name not in ('ValueOf', 'mro'):
|
||||||
attrs=inspect.getmembers(sub)
|
print_with(attr_name,"attribute",3)
|
||||||
for attr_name,attr in attrs:
|
elif inspect.ismethoddescriptor(sub):
|
||||||
if not attr_name.startswith('__'):
|
print_with(sub_name,"method",2)
|
||||||
lw.WriteLine(f" attr:{attr_name}:{type(attr).__name__}")
|
#lw.WriteLine(f"{sub}")
|
||||||
|
else:
|
||||||
|
print_with(sub_name,"attribute",2)
|
||||||
|
|
||||||
funcs = inspect.getmembers(cls)
|
|
||||||
for func_name, func in funcs:
|
|
||||||
_type=type(func).__name__
|
|
||||||
# 过滤掉以双下划线开头的成员
|
|
||||||
if not func_name.startswith('__') and not func_name.startswith('_'):
|
|
||||||
#过滤掉影响阅读的成员
|
|
||||||
if not (type(func).__name__).startswith('method_descriptor') \
|
|
||||||
and not (type(func).__name__).startswith('getset_descriptor') \
|
|
||||||
and not (type(func).__name__).startswith('builtin_function_or_method') \
|
|
||||||
and not (type(func).__name__).startswith('type'):
|
|
||||||
_type=type(func).__name__
|
|
||||||
lw.WriteLine(f" func:{func_name}:{_type}")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#"----------该脚本屏蔽内容如下:-----------"
|
#"----------该脚本屏蔽内容如下:-----------"
|
||||||
#"__"
|
#"__"
|
||||||
|
Loading…
Reference in New Issue
Block a user