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 args = sys.argv[2:] 17 i = micropython.Importer(sys.path, "-v" in args) 18 19 if "-omax" in args: 20 requested_optimisations = i.supported_optimisations 21 else: 22 requested_optimisations = [] 23 for arg in args: 24 if arg.startswith("-o"): 25 requested_optimisations.append(arg[2:]) 26 27 try: 28 builtins = i.load_from_file("lib/builtins.py", "__builtins__") 29 if len(sys.argv) < 2: 30 m = i.load("micropython") 31 #m = i.load_from_file("micropython/__init__.py") 32 else: 33 m = i.load_from_file(sys.argv[1]) 34 except micropython.ProcessingError, exc: 35 print repr(exc) 36 else: 37 i.vacuum() 38 ot = i.get_object_table() 39 pt = i.get_parameter_table() 40 41 # vim: tabstop=4 expandtab shiftwidth=4