1.1 --- a/simplify.py Sat Dec 09 00:36:06 2006 +0100
1.2 +++ b/simplify.py Sat Dec 09 02:16:20 2006 +0100
1.3 @@ -713,7 +713,7 @@
1.4 _names = []
1.5 code.append(
1.6 StoreTemp(
1.7 - expr=Import(name=from_.modname)
1.8 + expr=Import(name=from_.modname, alias=1)
1.9 )
1.10 )
1.11 from_._modname = code[-1].expr
1.12 @@ -886,7 +886,7 @@
1.13 code = []
1.14 _names = []
1.15 for path, alias in import_.names:
1.16 - importer = Import(name=path)
1.17 + importer = Import(name=path, alias=alias)
1.18 top = alias or path.split(".")[0]
1.19 code.append(StoreName(expr=importer, name=top))
1.20 _names.append(code[-1].expr)
1.21 @@ -1460,7 +1460,7 @@
1.22
1.23 # Convenience functions.
1.24
1.25 -def simplify(filename, builtins=0):
1.26 +def simplify(filename, builtins=0, module_name=None):
1.27
1.28 """
1.29 Simplify the module stored in the file with the given 'filename'.
1.30 @@ -1473,10 +1473,11 @@
1.31 module = compiler.parseFile(filename)
1.32 compiler.misc.set_filename(filename, module)
1.33 if builtins:
1.34 - name = "__builtins__"
1.35 + name = module_name or "__builtins__"
1.36 else:
1.37 path, ext = os.path.splitext(filename)
1.38 path, name = os.path.split(path)
1.39 + name = module_name or name
1.40 simplified = simplifier.process(module, name)
1.41 return simplified
1.42