def _to_require(self, fname, path=None): path = shorten_submodule_path(path) modtable = self.modtable if modtable.builtin(fname): return VOID fname = rpath.realpath(fname) return Require(fname, self, path=path)
def expand_to_ast(self, fname): assert fname is not None fname = rpath.realpath(fname) data = expand_file_rpython(fname, self._lib_string()) self.modtable.enter_module(fname) module = self.to_module(pycket_json.loads(data)) module = finalize_module(module) self.modtable.exit_module(fname, module) return module
def load_json_ast_rpython(self, modname, fname): assert modname is not None modname = rpath.realpath(modname) data = readfile_rpython(fname) self.modtable.enter_module(modname) module = self.to_module(pycket_json.loads(data)) module = finalize_module(module) self.modtable.exit_module(modname, module) return module
def parse_path(p): assert len(p) >= 1 arr = convert_path(p) srcmod, path = arr[0], arr[1:] # Relative module names go into the path. # None value for the srcmod indicate the current module if srcmod in (".", ".."): return None, arr if not ModTable.builtin(srcmod): srcmod = rpath.realpath(srcmod) return srcmod, path
def load_json_ast_rpython(self, modname, fname): assert modname is not None modname = rpath.realpath(modname) self.modtable.enter_module(modname) if self.multi_mod_flag: mod_ast = self.multi_mod_mapper.get_mod(modname) module = self.to_module(mod_ast) else: data = readfile_rpython(fname) module = self.to_module(pycket_json.loads(data)) module = finalize_module(module) self.modtable.exit_module(modname, module) return module
def __init__(self, json_file_name): assert json_file_name is not None and json_file_name != "" data = readfile_rpython(rpath.realpath(os.path.abspath(json_file_name))) self.source_json = json_file_name self.mod_map = pycket_json.loads(data)