MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _main

Function _main

tools/python-3.11.9-amd64/Lib/pyclbr.py:275–311  ·  view source on GitHub ↗

Print module output (default this file) for quick visual check.

()

Source from the content-addressed store, hash-verified

273
274
275def _main():
276 "Print module output (default this file) for quick visual check."
277 import os
278 try:
279 mod = sys.argv[1]
280 except:
281 mod = __file__
282 if os.path.exists(mod):
283 path = [os.path.dirname(mod)]
284 mod = os.path.basename(mod)
285 if mod.lower().endswith(".py"):
286 mod = mod[:-3]
287 else:
288 path = []
289 tree = readmodule_ex(mod, path)
290 lineno_key = lambda a: getattr(a, 'lineno', 0)
291 objs = sorted(tree.values(), key=lineno_key, reverse=True)
292 indent_level = 2
293 while objs:
294 obj = objs.pop()
295 if isinstance(obj, list):
296 # Value is a __path__ key.
297 continue
298 if not hasattr(obj, 'indent'):
299 obj.indent = 0
300
301 if isinstance(obj, _Object):
302 new_objs = sorted(obj.children.values(),
303 key=lineno_key, reverse=True)
304 for ob in new_objs:
305 ob.indent = obj.indent + indent_level
306 objs.extend(new_objs)
307 if isinstance(obj, Class):
308 print("{}class {} {} {}"
309 .format(' ' * obj.indent, obj.name, obj.super, obj.lineno))
310 elif isinstance(obj, Function):
311 print("{}def {} {}".format(' ' * obj.indent, obj.name, obj.lineno))
312
313if __name__ == "__main__":
314 _main()

Callers 1

pyclbr.pyFile · 0.70

Calls 11

readmodule_exFunction · 0.85
sortedFunction · 0.85
basenameMethod · 0.80
endswithMethod · 0.80
printFunction · 0.50
existsMethod · 0.45
lowerMethod · 0.45
valuesMethod · 0.45
popMethod · 0.45
extendMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected