Print module output (default this file) for quick visual check.
()
| 272 | |
| 273 | |
| 274 | def _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 | |
| 312 | if __name__ == "__main__": |
| 313 | _main() |
no test coverage detected
searching dependent graphs…