Commits

Anonymous committed a06a9fe

Eliminated module.is_package

Comments (0)

Files changed (3)

docs/workingon.txt

 
 Goals:
 
-* Go to definition for packages should go to __init__.py; for FilteredPackages also
+- Go to definition for packages should go to __init__.py; for FilteredPackages also
 * Do something for modules that can not be found
 * Dotted not found modules
 
 Problems with what we have right now:
 
-* PyFilteredPackages should have the __init__.py resource
+- PyFilteredPackages should have the __init__.py resource
+- module.is_package is scattered everywhere; replace it with isinstance
 * PyPackages should not expose all of their submodules
-* module.is_package is scattered everywhere; replace it with isinstance
 
 Possible solutions:
 
-* Eliminate PyFilteredPackage all together
+- Eliminate PyFilteredPackage all together
 * PyPackage should be filtered by itself
 
 
         super(PyModule, self).__init__(PyObject.get_base_type('Module'),
                                        pycore, ast_node, None)
         self.resource = resource
-        self.is_package = False
 
     def _update_attributes_from_ast(self, attributes):
         visitor = _GlobalVisitor(self.pycore, self)
 
     def __init__(self, pycore, resource=None):
         self.resource = resource
-        self.is_package = True
         if resource is not None and resource.has_child('__init__.py'):
             ast_node = compiler.parse(resource.get_child('__init__.py').read())
         else:
                 lineno = 1
             except ModuleNotFoundException:
                 module = PyObject(PyObject.get_base_type('Module'))
-                module.is_package = False
                 module_resource = None
                 lineno = None
             if alias is None and '.' in imported:
             module = PyPackage(self.pycore)
 
         if node.names[0][0] == '*':
-            if module.is_package:
+            if isinstance(module, PyPackage):
                 return
             for name, pyname in module.get_attributes().iteritems():
                 if not name.startswith('_'):

ropetest/pycoretest.py

         sample_function = mod.get_attributes()['sample_function']
         self.assertEquals(['param1', 'param2', 'param3', 'param4'], sample_function.object.parameters)
 
-    def test_not_found_module_is_package(self):
+    def test_not_found_module_is_module(self):
         mod = self.pycore.get_string_module('import doesnotexist\n')
-        self.assertFalse(mod.get_attributes()['doesnotexist'].object.is_package)
+        self.assertEquals(PyObject.get_base_type('Module'), 
+                          mod.get_attributes()['doesnotexist'].get_type())
 
     def test_mixing_scopes_and_objects_hierarchy(self):
         mod = self.pycore.get_string_module('var = 200\n')