重写函数和类输出
This commit is contained in:
parent
2f7a4d3ec9
commit
eb7f717a5a
@ -17,29 +17,53 @@ lw = session.ListingWindow
|
|||||||
lw.Open()
|
lw.Open()
|
||||||
|
|
||||||
# 定义要检查的模块列表,具体要检查的模块自行设定,不建议设置太多模块同时导出,会卡死你的!
|
# 定义要检查的模块列表,具体要检查的模块自行设定,不建议设置太多模块同时导出,会卡死你的!
|
||||||
modules = [NXOpen.CAM]
|
modules = [NXOpen]
|
||||||
|
|
||||||
|
def f_type(sub):
|
||||||
|
attrs=inspect.getmembers(sub)
|
||||||
|
for attr_name,attr in attrs:
|
||||||
|
if not attr_name.startswith('__') and not attr_name.startswith('builtin_function_or_method'):
|
||||||
|
return type(attr).__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,inspect.isclass)
|
classes = inspect.getmembers(module)
|
||||||
for cls_name,cls in classes:
|
for cls_name,cls in classes:
|
||||||
lw.WriteLine(f" class:{module.__name__}.{cls_name}")
|
# 过滤掉以双下划线开头的成员
|
||||||
cls_subs = inspect.getmembers(cls,inspect.isclass)
|
if not cls_name.startswith('__') and not cls_name.startswith('_'):
|
||||||
for cls_sub_name, cls_cls in cls_subs:
|
lw.WriteLine(f"class: {module.__name__}.{cls_name}")
|
||||||
if not cls_sub_name.startswith('__'):
|
# 获取类的所有成员
|
||||||
lw.WriteLine(f" subclass:{cls_sub_name}")
|
subs = inspect.getmembers(cls,inspect.isclass)
|
||||||
for member in dir(cls_cls):
|
for sub_name, sub in subs:
|
||||||
if not member.startswith('__'):
|
if not sub_name.startswith('__'):
|
||||||
lw.WriteLine(f" member:{member}:{type(member).__name__}")
|
lw.WriteLine(f" types:{sub_name}")
|
||||||
|
attrs=inspect.getmembers(sub)
|
||||||
|
for attr_name,attr in attrs:
|
||||||
|
if not attr_name.startswith('__'):
|
||||||
|
lw.WriteLine(f" attr:{attr_name}:{type(attr).__name__}")
|
||||||
|
|
||||||
|
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__':
|
||||||
"#----------ban words:-----------"
|
#"----------该脚本屏蔽内容如下:-----------"
|
||||||
"__"
|
#"__"
|
||||||
"_"
|
#"_"
|
||||||
"method_descriptor"
|
#"method_descriptor"
|
||||||
"getset_descriptor"
|
#"getset_descriptor"
|
||||||
"builtin_function_or_method"
|
#f"builtin_function_or_method"
|
||||||
"-------------------------------------"
|
#"-------------------------------------"
|
||||||
"#屏蔽以上内容方便API的阅读,被屏蔽掉的内容作者认为是python内置或者绑定函数,对象,成员.阅读意义不大"
|
#"屏蔽以上内容方便API的阅读,被屏蔽掉的内容作者认为是python内置或者绑定函数,对象,成员.阅读意义不大"
|
||||||
main()
|
main()
|
||||||
Loading…
Reference in New Issue
Block a user