Anonymous avatar Anonymous committed 2b44db8

importutils: renamed ImportTools.get_module_imports() to module_imports

Comments (0)

Files changed (5)

rope/contrib/generate.py

 def _add_import_to_module(pycore, resource, imported):
     pymodule = pycore.resource_to_pyobject(resource)
     import_tools = importutils.ImportTools(pycore)
-    module_imports = import_tools.get_module_imports(pymodule)
+    module_imports = import_tools.module_imports(pymodule)
     module_name = importutils.get_module_name(pycore, imported)
     new_import = importutils.NormalImport(((module_name, None), ))
     module_imports.add_import(new_import)

rope/refactor/importutils/__init__.py

             names = [(name, None),]
         return FromImport(module_name, 0, tuple(names))
 
-    def get_module_imports(self, module, imports_filter=None):
+    def module_imports(self, module, imports_filter=None):
         return module_imports.ModuleImports(self.pycore, module,
                                             imports_filter)
 
     def froms_to_imports(self, pymodule, import_filter=None):
         pymodule = self._clean_up_imports(pymodule, import_filter)
-        module_imports = self.get_module_imports(pymodule, import_filter)
+        module_imports = self.module_imports(pymodule, import_filter)
         for import_stmt in module_imports.get_import_statements():
             if import_stmt.readonly or \
                not self._is_transformable_to_normal(import_stmt.import_info):
             pymodule = self._from_to_normal(pymodule, import_stmt)
 
         # Adding normal imports in place of froms
-        module_imports = self.get_module_imports(pymodule, import_filter)
+        module_imports = self.module_imports(pymodule, import_filter)
         for import_stmt in module_imports.get_import_statements():
             if not import_stmt.readonly and \
                self._is_transformable_to_normal(import_stmt.import_info):
         return module_imports.get_changed_source()
 
     def expand_stars(self, pymodule, import_filter=None):
-        module_imports = self.get_module_imports(pymodule, import_filter)
+        module_imports = self.module_imports(pymodule, import_filter)
         module_imports.expand_stars()
         return module_imports.get_changed_source()
 
 
     def _clean_up_imports(self, pymodule, import_filter):
         resource = pymodule.get_resource()
-        module_with_imports = self.get_module_imports(pymodule, import_filter)
+        module_with_imports = self.module_imports(pymodule, import_filter)
         module_with_imports.expand_stars()
         source = module_with_imports.get_changed_source()
         if source is not None:
         if source is not None:
             pymodule = self.pycore.get_string_module(source, resource)
 
-        module_with_imports = self.get_module_imports(pymodule, import_filter)
+        module_with_imports = self.module_imports(pymodule, import_filter)
         module_with_imports.remove_duplicates()
         module_with_imports.remove_unused_imports()
         source = module_with_imports.get_changed_source()
         return pymodule
 
     def relatives_to_absolutes(self, pymodule, import_filter=None):
-        module_imports = self.get_module_imports(pymodule, import_filter)
+        module_imports = self.module_imports(pymodule, import_filter)
         to_be_absolute_list = module_imports.get_relative_to_absolute_list()
         for name, absolute_name in to_be_absolute_list:
             pymodule = self._rename_in_module(pymodule, name, absolute_name)
-        module_imports = self.get_module_imports(pymodule, import_filter)
+        module_imports = self.module_imports(pymodule, import_filter)
         module_imports.get_relative_to_absolute_list()
         source = module_imports.get_changed_source()
         if source is None:
                          unused=True, duplicates=True,
                          selfs=True, sort=True, import_filter=None):
         if unused or duplicates:
-            module_imports = self.get_module_imports(pymodule, import_filter)
+            module_imports = self.module_imports(pymodule, import_filter)
             if unused:
                 module_imports.remove_unused_imports()
             if duplicates:
             return pymodule.source_code
 
     def _remove_self_imports(self, pymodule, import_filter=None):
-        module_imports = self.get_module_imports(pymodule, import_filter)
+        module_imports = self.module_imports(pymodule, import_filter)
         to_be_fixed, to_be_renamed = module_imports.get_self_import_fix_and_rename_list()
         for name in to_be_fixed:
             try:
                 return pymodule
         for name, new_name in to_be_renamed:
             pymodule = self._rename_in_module(pymodule, name, new_name)
-        module_imports = self.get_module_imports(pymodule, import_filter)
+        module_imports = self.module_imports(pymodule, import_filter)
         module_imports.get_self_import_fix_and_rename_list()
         source = module_imports.get_changed_source()
         if source is not None:
         return pymodule
 
     def sort_imports(self, pymodule, import_filter=None):
-        module_imports = self.get_module_imports(pymodule, import_filter)
+        module_imports = self.module_imports(pymodule, import_filter)
         module_imports.sort_imports()
         return module_imports.get_changed_source()
 
                             import_filter=None):
         # IDEA: `maxdots` and `maxlength` can be specified in project config
         # adding new from imports
-        module_imports = self.get_module_imports(pymodule, import_filter)
+        module_imports = self.module_imports(pymodule, import_filter)
         to_be_fixed = module_imports.handle_long_imports(maxdots, maxlength)
         # performing the renaming
         pymodule = self.pycore.get_string_module(

rope/refactor/inline.py

 
     def _init_imports(self):
         self.import_tools = importutils.ImportTools(self.pycore)
-        imports = importutils.get_imports(self.pycore, self.pyfunction)
         body = sourceutils.get_body(self.pyfunction)
-        body, imports = move._get_moving_element_with_imports(
-            self.pycore, self.resource, body, imports)
+        body, imports = move.moving_code_with_imports(
+            self.pycore, self.resource, body)
         self.imports = imports
         self.others_generator = _DefinitionGenerator(
             self.project, self.pyfunction, body=body)

rope/refactor/move.py

         pymodule = self.tools.new_pymodule(pymodule, source)
         pymodule, has_changed = self._add_imports2(pymodule, imports)
 
-        module_with_imports = self.import_tools.get_module_imports(pymodule)
+        module_with_imports = self.import_tools.module_imports(pymodule)
         source = pymodule.source_code
         if module_with_imports.get_import_statements():
             start = pymodule.lines.get_line_end(
         return ChangeContents(dest, source)
 
     def _get_moving_element_with_imports(self):
-        return _get_moving_element_with_imports(
-            self.pycore, self.source, self._get_moving_element(),
-            self._get_used_imports_by_the_moving_element())
+        return moving_code_with_imports(
+            self.pycore, self.source, self._get_moving_element())
 
     def _get_module_with_imports(self, source_code, resource):
         pymodule = self.pycore.get_string_module(source_code, resource)
-        return self.import_tools.get_module_imports(pymodule)
+        return self.import_tools.module_imports(pymodule)
 
     def _get_moving_element(self):
         start, end = self._get_moving_region()
         end = min(lines.get_line_end(end_line) + 1, len(pymodule.source_code))
         return start, end
 
-    def _get_used_imports_by_the_moving_element(self):
-        return importutils.get_imports(self.pycore,
-                                       self.old_pyname.get_object())
-
     def _add_imports2(self, pymodule, new_imports):
         source = self.tools.add_imports(pymodule, new_imports)
         if source is None:
 
     def remove_old_imports(self, pymodule):
         old_source = pymodule.source_code
-        module_with_imports = self.import_tools.get_module_imports(pymodule)
+        module_with_imports = self.import_tools.module_imports(pymodule)
         class CanSelect(object):
             changed = False
             old_name = self.old_name
 
 
 def _add_imports_to_module(import_tools, pymodule, new_imports):
-    module_with_imports = import_tools.get_module_imports(pymodule)
+    module_with_imports = import_tools.module_imports(pymodule)
     for new_import in new_imports:
         module_with_imports.add_import(new_import)
     return module_with_imports.get_changed_source()
 
 
-def _get_moving_element_with_imports(pycore, resource, source, imports):
+def moving_code_with_imports(pycore, resource, source):
     import_tools = importutils.ImportTools(pycore)
-    new_imports = list(imports)
     pymodule = pycore.get_string_module(source, resource)
+    origin = pycore.resource_to_pyobject(resource)
+
+    imports = []
+    for stmt in import_tools.module_imports(origin).get_import_statements():
+        imports.append(stmt.import_info)
 
     back_names = []
-    for name in pycore.resource_to_pyobject(resource):
+    for name in origin:
         if name not in pymodule:
             back_names.append(name)
-    new_imports.append(import_tools.get_from_import(resource, back_names))
+    imports.append(import_tools.get_from_import(resource, back_names))
 
-    source = _add_imports_to_module(import_tools, pymodule, new_imports)
+    source = _add_imports_to_module(import_tools, pymodule, imports)
     pymodule = pycore.get_string_module(source, resource)
 
     source = import_tools.relatives_to_absolutes(pymodule)
     pymodule = pycore.get_string_module(source, resource)
 
     # extracting imports after changes
-    module_with_imports = import_tools.get_module_imports(pymodule)
+    module_with_imports = import_tools.module_imports(pymodule)
     imports = [import_stmt.import_info
                for import_stmt in module_with_imports.get_import_statements()]
     start = 1

ropetest/refactor/importutilstest.py

     def test_get_import_statements(self):
         self.mod.write('import pkg1\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_import_statements()
         self.assertEquals('import pkg1',
                           imports[0].import_info.get_import_statement())
     def test_get_import_statements_with_alias(self):
         self.mod.write('import pkg1.mod1 as mod1\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_import_statements()
         self.assertEquals('import pkg1.mod1 as mod1',
                           imports[0].import_info.get_import_statement())
     def test_get_import_statements_for_froms(self):
         self.mod.write('from pkg1 import mod1\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_import_statements()
         self.assertEquals('from pkg1 import mod1',
                           imports[0].import_info.get_import_statement())
     def test_get_multi_line_import_statements_for_froms(self):
         self.mod.write('from pkg1 \\\n    import mod1\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_import_statements()
         self.assertEquals('from pkg1 import mod1',
                           imports[0].import_info.get_import_statement())
     def test_get_import_statements_for_from_star(self):
         self.mod.write('from pkg1 import *\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_import_statements()
         self.assertEquals('from pkg1 import *',
                           imports[0].import_info.get_import_statement())
     def test_get_import_statements_for_new_relatives(self):
         self.mod2.write('from .mod3 import x\n')
         pymod = self.pycore.get_module('pkg2.mod2')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_import_statements()
         self.assertEquals('from .mod3 import x',
                           imports[0].import_info.get_import_statement())
     def test_ignoring_indented_imports(self):
         self.mod.write('if True:\n    import pkg1\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_import_statements()
         self.assertEquals(0, len(imports))
 
     def test_import_get_names(self):
         self.mod.write('import pkg1 as pkg\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_import_statements()
         context = importinfo.ImportContext(self.pycore, self.project.root)
         self.assertEquals(['pkg'],
     def test_import_get_names_with_alias(self):
         self.mod.write('import pkg1.mod1\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_import_statements()
         context = importinfo.ImportContext(self.pycore, self.project.root)
         self.assertEquals(['pkg1'],
         self.mod1.write('def a_func():\n    pass\n')
         self.mod.write('from pkg1.mod1 import *\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_import_statements()
         context = importinfo.ImportContext(self.pycore, self.project.root)
         self.assertEquals(['a_func'],
     def test_empty_getting_used_imports(self):
         self.mod.write('')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_used_imports(pymod)
         self.assertEquals(0, len(imports))
 
     def test_empty_getting_used_imports2(self):
         self.mod.write('import pkg\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_used_imports(pymod)
         self.assertEquals(0, len(imports))
 
     def test_simple_getting_used_imports(self):
         self.mod.write('import pkg\nprint(pkg)\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_used_imports(pymod)
         self.assertEquals(1, len(imports))
         self.assertEquals('import pkg', imports[0].get_import_statement())
     def test_simple_getting_used_imports2(self):
         self.mod.write('import pkg\ndef a_func():\n    print(pkg)\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_used_imports(pymod)
         self.assertEquals(1, len(imports))
         self.assertEquals('import pkg', imports[0].get_import_statement())
     def test_getting_used_imports_for_nested_scopes(self):
         self.mod.write('import pkg1\nprint(pkg1)\ndef a_func():\n    pass\nprint(pkg1)\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_used_imports(
             pymod['a_func'].get_object())
         self.assertEquals(0, len(imports))
     def test_getting_used_imports_for_nested_scopes2(self):
         self.mod.write('from pkg1 import mod1\ndef a_func():\n    print(mod1)\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_used_imports(
             pymod['a_func'].get_object())
         self.assertEquals(1, len(imports))
     def test_empty_removing_unused_imports(self):
         self.mod.write('import pkg1\nprint(pkg1)\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('import pkg1\nprint(pkg1)\n',
                           module_with_imports.get_changed_source())
     def test_simple_removing_unused_imports(self):
         self.mod.write('import pkg1\n\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('', module_with_imports.get_changed_source())
 
         self.mod1.write('def a_func():\n    pass\ndef another_func():\n    pass\n')
         self.mod.write('from pkg1.mod1 import a_func, another_func\n\na_func()\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('from pkg1.mod1 import a_func\n\na_func()\n',
                           module_with_imports.get_changed_source())
     def test_simple_removing_unused_imports_for_from_stars(self):
         self.mod.write('from pkg1.mod1 import *\n\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('', module_with_imports.get_changed_source())
 
         self.mod1.write('def a_func():\n    pass\n')
         self.mod.write('import pkg1.mod1\npkg1.mod1.a_func()')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('import pkg1.mod1\npkg1.mod1.a_func()',
                           module_with_imports.get_changed_source())
     def test_removing_unused_imports_and_functions_of_the_same_name(self):
         self.mod.write('def a_func():\n    pass\ndef a_func():\n    pass\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('def a_func():\n    pass\ndef a_func():\n    pass\n',
                           module_with_imports.get_changed_source())
         self.mod.write('a_var = 1\n')
         self.mod1.write('from mod import a_var as myvar\na_var = myvar\n')
         pymod = self.pycore.resource_to_pyobject(self.mod1)
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('from mod import a_var as myvar\na_var = myvar\n',
                           module_with_imports.get_changed_source())
                '    def f(self):\n        a_var = pkg1\n'
         self.mod.write(code)
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals(code, module_with_imports.get_changed_source())
 
     def test_adding_imports(self):
         self.mod.write('\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         new_import = self.import_tools.get_import(self.mod1)
         module_with_imports.add_import(new_import)
         self.assertEquals('import pkg1.mod1\n',
         self.mod1.write('def a_func():\n    pass\ndef another_func():\n    pass\n')
         self.mod.write('from pkg1.mod1 import a_func\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         new_import = self.import_tools.get_from_import(
             self.mod1, 'another_func')
         module_with_imports.add_import(new_import)
         self.mod1.write('def a_func():\n    pass\ndef another_func():\n    pass\n')
         self.mod.write('from pkg1.mod1 import *\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         new_import = self.import_tools.get_from_import(
             self.mod1, 'another_func')
         module_with_imports.add_import(new_import)
         self.mod1.write('def a_func():\n    pass\ndef another_func():\n    pass\n')
         self.mod.write('from pkg1.mod1 import a_func\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         new_import = self.import_tools.get_from_import(self.mod1,
                                                                   '*')
         module_with_imports.add_import(new_import)
     def test_adding_imports_and_preserving_spaces_after_imports(self):
         self.mod.write('import pkg1\n\n\nprint(pkg1)\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         new_import = self.import_tools.get_import(self.pkg2)
         module_with_imports.add_import(new_import)
         self.assertEquals('import pkg1\nimport pkg2\n\n\nprint(pkg1)\n',
         self.mod1.write('def a_func():\n    pass\ndef another_func():\n    pass\n')
         self.mod.write('from pkg1.mod1 import (a_func,\n    another_func)\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         self.assertEquals(
             'from pkg1.mod1 import (a_func,\n    another_func)\n',
             module_with_imports.get_changed_source())
         self.mod1.write('def a_func():\n    pass\ndef another_func():\n    pass\n')
         self.mod.write('from pkg1.mod1 import (a_func)\na_func()\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('from pkg1.mod1 import (a_func)\na_func()\n',
                           module_with_imports.get_changed_source())
         self.mod.write('from pkg1.mod1 import *\n'
                        'from pkg1.mod1 import a_func\na_func()\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('from pkg1.mod1 import *\na_func()\n',
                           module_with_imports.get_changed_source())
         self.mod.write('import pkg2.mod2\nimport pkg2.mod3\n'
                        'print(pkg2.mod2, pkg2.mod3)')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals(
             'import pkg2.mod2\nimport pkg2.mod3\nprint(pkg2.mod2, pkg2.mod3)',
     def test_removing_unused_imports_and_common_packages(self):
         self.mod.write('import pkg1.mod1\nimport pkg1\nprint(pkg1, pkg1.mod1)\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('import pkg1.mod1\nprint(pkg1, pkg1.mod1)\n',
                           module_with_imports.get_changed_source())
     def test_removing_unused_imports_and_common_packages_reversed(self):
         self.mod.write('import pkg1\nimport pkg1.mod1\nprint(pkg1, pkg1.mod1)\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_duplicates()
         self.assertEquals('import pkg1.mod1\nprint(pkg1, pkg1.mod1)\n',
                           module_with_imports.get_changed_source())
     def test_removing_unused_imports_and_common_packages2(self):
         self.mod.write('import pkg1.mod1\nimport pkg1.mod2\nprint(pkg1)\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('import pkg1.mod1\nprint(pkg1)\n',
                           module_with_imports.get_changed_source())
         self.mod1.write('def func1():\n    pass\n')
         self.mod.write('from pkg1.mod1 import func1\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('', module_with_imports.get_changed_source())
 
         self.mod1.write('def func1():\n    pass\n')
         self.mod.write('from pkg1.mod1 import func1\nfunc1()')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('from pkg1.mod1 import func1\nfunc1()',
                           module_with_imports.get_changed_source())
         self.mod.write('from pkg1.mod1 import func1\n'
                        'def a_func():\n    func1()\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals(
             'from pkg1.mod1 import func1\ndef a_func():\n    func1()\n',
         self.mod.write('from pkg1.mod1 import func1\nclass A(object):\n'
                        '    def a_func(self):\n        func1()\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('from pkg1.mod1 import func1\nclass A(object):\n'
                           '    def a_func(self):\n        func1()\n',
         self.mod1.write('class A(object):\n    def f(self):\n        pass\n')
         self.mod.write('from pkg1.mod1 import A\nvar = A().f()')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('from pkg1.mod1 import A\nvar = A().f()',
                           module_with_imports.get_changed_source())
         self.mod1.write('def func1():\n    pass\n')
         self.mod.write('import pkg1\ndef a_func(pkg1):\n    my_var = pkg1\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('def a_func(pkg1):\n    my_var = pkg1\n',
                           module_with_imports.get_changed_source())
         self.mod1.write('def a_func():\n    pass\ndef another_func():\n    pass\n')
         self.mod.write('from pkg1.mod1 import *\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.expand_stars()
         self.assertEquals('', module_with_imports.get_changed_source())
 
         self.mod1.write('def a_func():\n    pass\ndef another_func():\n    pass\n')
         self.mod.write('from pkg1.mod1 import *\na_func()\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.expand_stars()
         self.assertEquals('from pkg1.mod1 import a_func\na_func()\n',
                           module_with_imports.get_changed_source())
     def test_removing_duplicate_imports(self):
         self.mod.write('import pkg1\nimport pkg1\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_duplicates()
         self.assertEquals('import pkg1\n',
                           module_with_imports.get_changed_source())
     def test_removing_duplicates_and_reoccuring_names(self):
         self.mod.write('import pkg2.mod2\nimport pkg2.mod3\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_duplicates()
         self.assertEquals('import pkg2.mod2\nimport pkg2.mod3\n',
                           module_with_imports.get_changed_source())
         self.mod.write('from pkg1 import a_func\n'
                        'from pkg1 import a_func, another_func\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_duplicates()
         self.assertEquals('from pkg1 import a_func, another_func\n',
                           module_with_imports.get_changed_source())
     def test_empty_removing_unused_imports_and_eating_blank_lines(self):
         self.mod.write('import pkg1\nimport pkg2\n\n\nprint(pkg1)\n')
         pymod = self.pycore.get_module('mod')
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         module_with_imports.remove_unused_imports()
         self.assertEquals('import pkg1\n\n\nprint(pkg1)\n',
                           module_with_imports.get_changed_source())
             'from does_not_exist import func\n\nfunc()\n')
         pymod = self.pycore.get_module('mod')
 
-        module_with_imports = self.import_tools.get_module_imports(pymod)
+        module_with_imports = self.import_tools.module_imports(pymod)
         imports = module_with_imports.get_used_imports(pymod)
         self.assertEquals(1, len(imports))
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.