def code_from_nu(filename, instream): import NoodleMain code = NoodleMain.noodle_compile_stream(instream, filename) compiledfile = nucfiles.nuc_filename(filename) try: nucfiles.output_nuc(filename, code, compiledfile) except IOError: pass return code
def execfile(nu_file): """Execute the given noodle source, or its associated compiled-bytecode file if one is found with the same timestamp. Returns the exit code. """ nucname = nucfiles.find_nuc(nu_file) if nucname is not None: return run_noodle(nucfiles.nuc_code_object(nucname)) # Either no .nuc, or timestamps don't match codeobj = noodle_compile_file(nu_file) try: nucfiles.output_nuc(nu_file, codeobj, nucname) except IOError: pass return run_noodle(codeobj)
def noodle_to_nuc(infilename, outfilename=None): nucfiles.output_nuc( infilename, noodle_compile_file(infilename), outfilename )