Commits

Anonymous committed 73e3c9a

pycore: using shorter names

Comments (0)

Files changed (3)

rope/base/pycore.py

             return resource.name.endswith('.py')
         return self.python_matcher.does_match(resource)
 
-    def get_module(self, name, current_folder=None):
+    def get_module(self, name, folder=None):
         """Returns a `PyObject` if the module was found."""
-        module = self.find_module(name, current_folder)
+        module = self.find_module(name, folder)
         if module is None:
             module = self._builtin_module(name)
             if module is None:
     def _builtin_module(self, name):
         return self.extension_cache.get_pymodule(name)
 
-    def get_relative_module(self, name, current_folder, level):
-        module = self.find_relative_module(name, current_folder, level)
+    def get_relative_module(self, name, folder, level):
+        module = self.find_relative_module(name, folder, level)
         if module is None:
             raise ModuleNotFoundError('Module %s not found' % name)
         return self.resource_to_pyobject(module)
 
-    def get_string_module(self, module_content, resource=None,
-                          force_errors=False):
-        """Returns a `PyObject` object for the given module_content
+    def get_string_module(self, code, resource=None, force_errors=False):
+        """Returns a `PyObject` object for the given code
 
         If `force_errors` is `True`, `exceptions.ModuleSyntaxError` is
         raised if module has syntax errors.  This overrides
         ``ignore_syntax_errors`` project config.
 
         """
-        return PyModule(self, module_content, resource,
-                        force_errors=force_errors)
+        return PyModule(self, code, resource, force_errors=force_errors)
 
-    def get_string_scope(self, module_content, resource=None):
-        """Returns a `Scope` object for the given module_content"""
-        return self.get_string_module(module_content, resource).get_scope()
+    def get_string_scope(self, code, resource=None):
+        """Returns a `Scope` object for the given code"""
+        return self.get_string_module(code, resource).get_scope()
 
     def _invalidate_resource_cache(self, resource, new_resource=None):
         for observer in self.cache_observers:
             observer(resource)
 
-    def _find_module_in_source_folder(self, source_folder, module_name):
+    def _find_module_in_folder(self, folder, modname):
         result = []
-        module = source_folder
-        packages = module_name.split('.')
+        module = folder
+        packages = modname.split('.')
         for pkg in packages[:-1]:
             if  module.is_folder() and module.has_child(pkg):
                 module = module.get_child(pkg)
                 pass
         return result
 
-    def find_module(self, module_name, current_folder=None):
+    def find_module(self, modname, folder=None):
         """Returns a resource corresponding to the given module
 
         returns None if it can not be found
         """
-        module_resource_list = self._find_module_resource_list(module_name,
-                                                               current_folder)
-        if module_resource_list is not None:
-            return module_resource_list[-1]
+        resource_list = self._find_module(modname, folder)
+        if resource_list is not None:
+            return resource_list[-1]
 
-    def find_relative_module(self, module_name, current_folder, level):
+    def find_relative_module(self, modname, folder, level):
         for i in range(level - 1):
-            current_folder = current_folder.parent
-        if module_name == '':
-            return current_folder
+            folder = folder.parent
+        if modname == '':
+            return folder
         else:
-            module = self._find_module_in_source_folder(current_folder, module_name)
+            module = self._find_module_in_folder(folder, modname)
             if module is not None:
                 return module[-1]
 
-    def _find_module_resource_list(self, module_name, current_folder=None):
+    def _find_module(self, modname, folder=None):
         """Returns a list of lists of `Folder`s and `File`s for the given module"""
         for src in self.get_source_folders():
-            module = self._find_module_in_source_folder(src, module_name)
+            module = self._find_module_in_folder(src, modname)
             if module is not None:
                 return module
         for src in self.get_python_path_folders():
-            module = self._find_module_in_source_folder(src, module_name)
+            module = self._find_module_in_folder(src, modname)
             if module is not None:
                 return module
-        if current_folder is not None:
-            module = self._find_module_in_source_folder(current_folder,
-                                                        module_name)
+        if folder is not None:
+            module = self._find_module_in_folder(folder, modname)
             if module is not None:
                 return module
         return None

rope/refactor/importutils/actions.py

         self.to_be_absolute.extend(self._get_relative_to_absolute_list(import_info))
         new_pairs = []
         for name, alias in import_info.names_and_aliases:
-            resource = self.pycore.find_module(name, current_folder=self.folder)
+            resource = self.pycore.find_module(name, folder=self.folder)
             if resource is None:
                 new_pairs.append((name, alias))
                 continue
         for name, alias in import_info.names_and_aliases:
             if alias is not None:
                 continue
-            resource = self.pycore.find_module(name, current_folder=self.folder)
+            resource = self.pycore.find_module(name, folder=self.folder)
             if resource is None:
                 continue
             absolute_name = self.pycore.modname(resource)
     def visitNormalImport(self, import_stmt, import_info):
         new_pairs = []
         for name, alias in import_info.names_and_aliases:
-            resource = self.pycore.find_module(name, current_folder=self.folder)
+            resource = self.pycore.find_module(name, folder=self.folder)
             if resource is not None and resource == self.resource:
                 imported = name
                 if alias is not None:
         if import_info.names_and_aliases:
             name, alias = import_info.names_and_aliases[0]
             resource = self.pycore.find_module(
-                name, current_folder=self.folder)
+                name, folder=self.folder)
             self._check_imported_resource(import_stmt, resource, name)
 
     def visitFromImport(self, import_stmt, import_info):

rope/refactor/importutils/importinfo.py

         """
         if self.level == 0:
             return context.pycore.find_module(
-                self.module_name, current_folder=context.folder)
+                self.module_name, folder=context.folder)
         else:
             return context.pycore.find_relative_module(
                 self.module_name, context.folder, self.level)