diff options
Diffstat (limited to 'Lib/lib2to3/fixes/fix_imports.py')
-rw-r--r-- | Lib/lib2to3/fixes/fix_imports.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/Lib/lib2to3/fixes/fix_imports.py b/Lib/lib2to3/fixes/fix_imports.py index 08be543..46ba4a2 100644 --- a/Lib/lib2to3/fixes/fix_imports.py +++ b/Lib/lib2to3/fixes/fix_imports.py @@ -27,6 +27,7 @@ MAPPING = {'StringIO': 'io', 'ScrolledText': 'tkinter.scrolledtext', 'Tkconstants': 'tkinter.constants', 'Tix': 'tkinter.tix', + 'ttk': 'tkinter.ttk', 'Tkinter': 'tkinter', 'markupbase': '_markupbase', '_winreg': 'winreg', @@ -121,17 +122,18 @@ class FixImports(fixer_base.BaseFix): def transform(self, node, results): import_mod = results.get("module_name") if import_mod: - new_name = self.mapping[import_mod.value] + mod_name = import_mod.value + new_name = self.mapping[mod_name] import_mod.replace(Name(new_name, prefix=import_mod.get_prefix())) if "name_import" in results: # If it's not a "from x import x, y" or "import x as y" import, # marked its usage to be replaced. - self.replace[import_mod.value] = new_name + self.replace[mod_name] = new_name if "multiple_imports" in results: - # This is a nasty hack to fix multiple imports on a - # line (e.g., "import StringIO, urlparse"). The problem is that I - # can't figure out an easy way to make a pattern recognize the - # keys of MAPPING randomly sprinkled in an import statement. + # This is a nasty hack to fix multiple imports on a line (e.g., + # "import StringIO, urlparse"). The problem is that I can't + # figure out an easy way to make a pattern recognize the keys of + # MAPPING randomly sprinkled in an import statement. results = self.match(node) if results: self.transform(node, results) |