1.1 --- a/micropython/__init__.py Sun May 24 20:28:56 2009 +0200
1.2 +++ b/micropython/__init__.py Mon May 25 00:45:53 2009 +0200
1.3 @@ -47,6 +47,7 @@
1.4 import micropython.inspect
1.5 import micropython.table
1.6 import os
1.7 +
1.8 try:
1.9 set
1.10 except NameError:
1.11 @@ -448,6 +449,12 @@
1.12
1.13 return self.modules.values()
1.14
1.15 + def get_module(self, name):
1.16 +
1.17 + "Return the module with the given 'name'."
1.18 +
1.19 + return self.modules[name]
1.20 +
1.21 # General maintenance.
1.22
1.23 def vacuum(self):
1.24 @@ -736,4 +743,23 @@
1.25 continue
1.26 module.set_module(submodule, self.add_module(module.name + "." + submodule))
1.27
1.28 +# Convenience functions.
1.29 +
1.30 +def program(filename, path, requested_optimisations, verbose=0):
1.31 +
1.32 + """
1.33 + Return the program object for the program specified by the given 'filename',
1.34 + module search 'path' and 'requested_optimisations'.
1.35 + """
1.36 +
1.37 + i = micropython.Importer(path, verbose, requested_optimisations)
1.38 + p = micropython.Program(i, requested_optimisations)
1.39 +
1.40 + i.load_from_file("lib/builtins.py", "__builtins__")
1.41 +
1.42 + if filename is not None:
1.43 + i.load_from_file(filename)
1.44 +
1.45 + return p
1.46 +
1.47 # vim: tabstop=4 expandtab shiftwidth=4