1
0
forked from VimPlug/jedi

a (temporary) solution for the __file__ access issues in imported modules, see #408

This commit is contained in:
Dave Halter
2014-05-19 01:01:56 +02:00
parent 709c53a679
commit 08b48807e9
5 changed files with 41 additions and 4 deletions

View File

@@ -521,3 +521,23 @@ class FunctionExecution(Executable):
def __repr__(self):
return "<%s of %s>" % (type(self).__name__, self.base)
class ModuleWrapper(pr.Module):
def __init__(self, evaluator, module):
self._evaluator = evaluator
self._module = module
@memoize_default()
def get_defined_names(self):
names = ['__file__', '__package__', '__doc__', '__name__', '__version__']
# All the additional module attributes are strings.
parent = Instance(self._evaluator, compiled.create(self._evaluator, str))
module_attributes = [helpers.FakeName(n, parent) for n in names]
return self._module.get_defined_names() + module_attributes
def __getattr__(self, name):
return getattr(self._module, name)
def __repr__(self):
return "<%s: %s>" % (type(self).__name__, self._module)