def load(source): if path is not None and path.endswith('.py'): if source is None: with open(path) 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', '.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) 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
def parser(self): """ get the parser lazy """ if not self._parser: with common.ignored(KeyError): parser = cache.parser_cache[self.path].parser cache.invalidate_star_import_cache(parser.module) # Call the parser already here, because it will be used anyways. # Also, the position is here important (which will not be used by # default), therefore fill the cache here. self._parser = fast.FastParser(self.source, self.path, self.position) # don't pickle that module, because it's changing fast cache.save_module(self.path, self.name, self._parser, pickling=False) return self._parser
def _load_module(self): source = self._get_source() p = self.path or self.name p = fast.FastParser(source, p) cache.save_module(self.path, self.name, p) return p