Example #1
0
 def load(source):
     dotted_path = path and compiled.dotted_from_fs_path(path, sys_path)
     if path is not None and path.endswith(".py") and not dotted_path in settings.auto_import_modules:
         if source is None:
             with open(path, "rb") as f:
                 source = f.read()
     else:
         return compiled.load_module(path)
     p = path
     p = fast.FastParser(evaluator.grammar, common.source_to_unicode(source), p)
     cache.save_parser(path, p)
     return p.module
Example #2
0
 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 = FastParser(evaluator.grammar, source_to_unicode(source), p)
     save_parser(path, p)
     return p.module
Example #3
0
 def load(source):
     dotted_path = path and compiled.dotted_from_fs_path(path, sys_path)
     if path is not None and path.endswith('.py') \
             and not dotted_path in settings.auto_import_modules:
         if source is None:
             with open(path, 'rb') as f:
                 source = f.read()
     else:
         return compiled.load_module(path, name)
     p = path or name
     p = fast.FastParser(common.source_to_unicode(source), p)
     cache.save_parser(path, name, p)
     return p.module
 def load(source):
     dotted_path = path and compiled.dotted_from_fs_path(path, sys_path)
     if path is not None and path.endswith('.py') \
             and not dotted_path in settings.auto_import_modules:
         if source is None:
             with open(path, 'rb') as f:
                 source = f.read()
     else:
         return compiled.load_module(path, name)
     p = path or name
     p = fast.FastParser(evaluator.grammar, common.source_to_unicode(source), p)
     cache.save_parser(path, name, p)
     return p.module
Example #5
0
def _load_module(evaluator, path=None, code=None, sys_path=None, parent_module=None):
    if sys_path is None:
        sys_path = evaluator.sys_path

    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:

        module_node = parse(code=code, path=path, cache=True, diff_cache=True)

        from jedi.evaluate.representation import ModuleContext
        return ModuleContext(evaluator, module_node, path=path)
    else:
        return compiled.load_module(evaluator, path)
 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)
Example #7
0
def _load_module(evaluator, path=None, code=None, sys_path=None, parent_module=None):
    if sys_path is None:
        sys_path = evaluator.sys_path

    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:

        module_node = parse(code=code, path=path, cache=True, diff_cache=True)

        from jedi.evaluate.representation import ModuleContext
        return ModuleContext(evaluator, module_node, path=path)
    else:
        return compiled.load_module(evaluator, path)
Example #8
0
 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)