def __init__(self, evaluator, parser_module, namespaces): self._evaluator = evaluator self._namespaces = namespaces self._namespace_objects = [ type('jedi_namespace', (), n) for n in namespaces ] self._wrapped_module = ModuleWrapper(evaluator, parser_module) # Usually we are dealing with very small code sizes when it comes to # interpreter modules. In this case we just copy the whole syntax tree # to be able to modify it. self._parser_module = copy.deepcopy(parser_module) for child in self._parser_module.children: child.parent = self
class MixedModule(object): resets_positions = True type = 'mixed_module' def __init__(self, evaluator, parser_module, namespaces): self._evaluator = evaluator self._namespaces = namespaces self._namespace_objects = [type('jedi_namespace', (), n) for n in namespaces] self._wrapped_module = ModuleWrapper(evaluator, parser_module) # Usually we are dealing with very small code sizes when it comes to # interpreter modules. In this case we just copy the whole syntax tree # to be able to modify it. self._parser_module = copy.deepcopy(parser_module) for child in self._parser_module.children: child.parent = self def names_dicts(self, search_global): for names_dict in self._wrapped_module.names_dicts(search_global): yield names_dict for namespace_obj in self._namespace_objects: m = mixed.MixedObject(self._evaluator, namespace_obj, self._parser_module.name) for names_dict in m.names_dicts(False): yield names_dict def __getattr__(self, name): return getattr(self._parser_module, name)
class MixedModule(object): resets_positions = True type = 'mixed_module' def __init__(self, evaluator, parser_module, namespaces): self._evaluator = evaluator self._namespaces = namespaces self._namespace_objects = [ type('jedi_namespace', (), n) for n in namespaces ] self._wrapped_module = ModuleWrapper(evaluator, parser_module) # Usually we are dealing with very small code sizes when it comes to # interpreter modules. In this case we just copy the whole syntax tree # to be able to modify it. self._parser_module = copy.deepcopy(parser_module) for child in self._parser_module.children: child.parent = self def names_dicts(self, search_global): for names_dict in self._wrapped_module.names_dicts(search_global): yield names_dict for namespace_obj in self._namespace_objects: m = mixed.MixedObject(self._evaluator, namespace_obj, self._parser_module.name) for names_dict in m.names_dicts(False): yield names_dict def __getattr__(self, name): return getattr(self._parser_module, name)
def _real_follow_file_system(self): if self.file_path: sys_path_mod = list(self.sys_path_with_modifications()) if not self.module.has_explicit_absolute_import: # If the module explicitly asks for absolute imports, # there's probably a bogus local one. sys_path_mod.insert(0, self.file_path) # First the sys path is searched normally and if that doesn't # succeed, try to search the parent directories, because sometimes # Jedi doesn't recognize sys.path modifications (like py.test # stuff). old_path, temp_path = self.file_path, os.path.dirname( self.file_path) while old_path != temp_path: sys_path_mod.append(temp_path) old_path, temp_path = temp_path, os.path.dirname(temp_path) else: sys_path_mod = list(get_sys_path()) from jedi.evaluate.representation import ModuleWrapper module, rest = self._follow_sys_path(sys_path_mod) if isinstance(module, pr.Module): return ModuleWrapper(self._evaluator, module), rest return module, rest
def __init__(self, evaluator, parser_module, namespaces): self._evaluator = evaluator self._namespaces = namespaces self._namespace_objects = [type('jedi_namespace', (), n) for n in namespaces] self._wrapped_module = ModuleWrapper(evaluator, parser_module) # Usually we are dealing with very small code sizes when it comes to # interpreter modules. In this case we just copy the whole syntax tree # to be able to modify it. self._parser_module = copy.deepcopy(parser_module) for child in self._parser_module.children: child.parent = self
def load(source): dotted_path = path and compiled.dotted_from_fs_path(path, sys_path) if path is not None and path.endswith(('.py', '.zip', '.egg')) \ and dotted_path not in settings.auto_import_modules: if source is None: with open(path, 'rb') as f: source = f.read() else: return compiled.load_module(evaluator, path) p = path p = fast.FastParser(evaluator.grammar, common.source_to_unicode(source), p) save_parser(path, p) from jedi.evaluate.representation import ModuleWrapper return ModuleWrapper(evaluator, p.module, parent_module)