MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / generate

Function generate

tools/python-3.11.9-amd64/Tools/scripts/deepfreeze.py:460–480  ·  view source on GitHub ↗
(args: list[str], output: TextIO)

Source from the content-addressed store, hash-verified

458
459
460def generate(args: list[str], output: TextIO) -> None:
461 printer = Printer(output)
462 for arg in args:
463 file, modname = arg.rsplit(':', 1)
464 with open(file, "r", encoding="utf8") as fd:
465 source = fd.read()
466 if is_frozen_header(source):
467 code = decode_frozen_data(source)
468 else:
469 code = compile(fd.read(), f"<frozen {modname}>", "exec")
470 printer.generate_file(modname, code)
471 with printer.block(f"void\n_Py_Deepfreeze_Fini(void)"):
472 for p in printer.deallocs:
473 printer.write(p)
474 with printer.block(f"int\n_Py_Deepfreeze_Init(void)"):
475 for p in printer.interns:
476 with printer.block(f"if ({p} < 0)"):
477 printer.write("return -1;")
478 printer.write("return 0;")
479 if verbose:
480 print(f"Cache hits: {printer.hits}, misses: {printer.misses}")
481
482
483parser = argparse.ArgumentParser()

Callers 1

mainFunction · 0.70

Calls 11

generate_fileMethod · 0.95
blockMethod · 0.95
writeMethod · 0.95
is_frozen_headerFunction · 0.85
decode_frozen_dataFunction · 0.85
rsplitMethod · 0.80
PrinterClass · 0.70
openFunction · 0.50
compileFunction · 0.50
printFunction · 0.50
readMethod · 0.45

Tested by

no test coverage detected