MCPcopy Index your code
hub / github.com/python/cpython / _main

Function _main

Lib/pyclbr.py:274–310  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

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

Callers 1

pyclbr.pyFile · 0.70

Calls 10

readmodule_exFunction · 0.85
existsMethod · 0.45
dirnameMethod · 0.45
basenameMethod · 0.45
endswithMethod · 0.45
lowerMethod · 0.45
valuesMethod · 0.45
popMethod · 0.45
extendMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…