1
0
forked from VimPlug/jedi

Some Python 2.7 fixes

This commit is contained in:
Dave Halter
2018-12-07 08:58:17 +01:00
parent b2824a3547
commit decb5046ea
8 changed files with 58 additions and 39 deletions

View File

@@ -172,6 +172,9 @@ class ModuleContext(ModuleMixin, TreeContext):
return os.path.abspath(self._path)
def _is_package(self):
return self._get_init_directory() is not None
def py__package__(self):
if self._get_init_directory() is None:
return re.sub(r'\.?[^.]+$', '', self.py__name__())
@@ -215,12 +218,10 @@ class ModuleContext(ModuleMixin, TreeContext):
is a list of paths (strings).
Raises an AttributeError if the module is not a package.
"""
path = self._get_init_directory()
if path is None:
raise AttributeError('Only packages have __path__ attributes.')
else:
if self._is_package():
return self._py__path__
else:
raise AttributeError('Only packages have __path__ attributes.')
def __repr__(self):
return "<%s: %s@%s-%s is_stub=%s>" % (