Anonymous avatar Anonymous committed 0e54ecf

pyobjectsdef: handling extension modules under packages

Comments (0)

Files changed (2)

rope/base/builtins.py

         result = _object_attributes(self.module, self)
         result.update(self.initial)
         for modname in self.submodules:
-            name = modname.split('.')[-1]
-            result[name] = BuiltinModule(modname, self.submodules)
+            name = modname[len(self.name) + 1:]
+            if '.' not in name:
+                result[name] = BuiltinModule(modname, self.submodules)
         return result
 
     @property
     @utils.cacheit
     def module(self):
         try:
-            return __import__(self.name)
+            result = __import__(self.name)
+            for token in self.name.split('.')[1:]:
+                result = getattr(result, token, None)
+            return result
         except ImportError:
             return
 
         for modname in self.modnames:
             prefix = self.name + '.'
             if modname.startswith(prefix):
-                modnames.append(modname[len(prefix):])
+                modnames.append(modname)
         return modnames
 
 

rope/base/pyobjectsdef.py

 
     def _create_structural_attributes(self):
         result = {}
+        modname = self.pycore.modname(self.resource)
+        for extension in self.pycore.extension_cache.allowed:
+            if extension.startswith(modname + '.'):
+                name = extension[len(modname) + 1:]
+                if '.' not in name:
+                    module = rope.base.builtins.BuiltinModule(
+                        extension, self.pycore.extension_cache.allowed)
+                    result[name] = rope.base.builtins.BuiltinName(module)
         if self.resource is None:
             return result
         for name, resource in self._get_child_resources().items():
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.