Anonymous avatar Anonymous committed 0e54ecf

pyobjectsdef: handling extension modules under packages

Comments (0)

Files changed (2)


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


     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
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.