MCPcopy Index your code
hub / github.com/RustPython/RustPython / main

Function main

Lib/symtable.py:419–446  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

417
418
419def main(args):
420 import sys
421 def print_symbols(table, level=0):
422 indent = ' ' * level
423 nested = "nested " if table.is_nested() else ""
424 if table.get_type() == 'module':
425 what = f'from file {table._filename!r}'
426 else:
427 what = f'{table.get_name()!r}'
428 print(f'{indent}symbol table for {nested}{table.get_type()} {what}:')
429 for ident in table.get_identifiers():
430 symbol = table.lookup(ident)
431 flags = ', '.join(symbol._flags_str()).lower()
432 print(f' {indent}{symbol._scope_str().lower()} symbol {symbol.get_name()!r}: {flags}')
433 print()
434
435 for table2 in table.get_children():
436 print_symbols(table2, level + 1)
437
438 for filename in args or ['-']:
439 if filename == '-':
440 src = sys.stdin.read()
441 filename = '<stdin>'
442 else:
443 with open(filename, 'rb') as f:
444 src = f.read()
445 mod = symtable(src, filename, 'exec')
446 print_symbols(mod)
447
448
449if __name__ == "__main__":

Callers 1

symtable.pyFile · 0.70

Calls 4

print_symbolsFunction · 0.85
openFunction · 0.70
symtableFunction · 0.70
readMethod · 0.45

Tested by

no test coverage detected