1 #!/usr/bin/env python 2 3 import micropython 4 import sys 5 6 def show(importer, with_builtins=0, optimisations=None): 7 optimisations = optimisations or requested_optimisations 8 for i, x in enumerate(importer.get_image(with_builtins, optimisations)): 9 print i, x 10 11 def attrs(obj): 12 for name, attr in obj.items(): 13 print name, attr 14 15 if __name__ == "__main__": 16 requested_optimisations = [] 17 for arg in sys.argv[2:]: 18 if arg.startswith("-o"): 19 requested_optimisations.append(arg[2:]) 20 21 i = micropython.Importer(sys.path, "-v" in sys.argv) 22 try: 23 builtins = i.load_from_file("lib/builtins.py", "__builtins__") 24 if len(sys.argv) < 2: 25 m = i.load("micropython") 26 #m = i.load_from_file("micropython/__init__.py") 27 else: 28 m = i.load_from_file(sys.argv[1]) 29 except micropython.ProcessingError, exc: 30 print repr(exc) 31 else: 32 i.vacuum() 33 ot = i.get_object_table() 34 pt = i.get_parameter_table() 35 36 # vim: tabstop=4 expandtab shiftwidth=4