GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — cpython/Programs/freeze_test_frozenmain.py at main · ramvikrams/cpython Expand file tree/ Copy pathfreeze_test_frozenmain.pyMore file actions 48 lines (35 loc) · 1.21 KB / Copy pathfreeze_test_frozenmain.pyFile metadata and controls48 lines (35 loc) · 1.21 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 import marshal import tokenize import os.path import sys PROGRAM_DIR = os.path.dirname(__file__) SRC_DIR = os.path.dirname(PROGRAM_DIR) def writecode(fp, mod, data): print('unsigned char M_%s[] = {' % mod, file=fp) indent = ' ' * 4 for i in range(0, len(data), 16): print(indent, file=fp, end='') for c in bytes(data[i:i+16]): print('%d,' % c, file=fp, end='') print('', file=fp) print('};', file=fp) def dump(fp, filename, name): # Strip the directory to get reproducible marshal dump code_filename = os.path.basename(filename) with tokenize.open(filename) as source_fp: source = source_fp.read() code = compile(source, code_filename, 'exec') data = marshal.dumps(code) writecode(fp, name, data) def main(): if len(sys.argv) < 2: print(f"usage: {sys.argv[0]} filename") sys.exit(1) filename = sys.argv[1] with open(filename, "w") as fp: print("// Auto-generated by Programs/freeze_test_frozenmain.py", file=fp) frozenmain = os.path.join(PROGRAM_DIR, 'test_frozenmain.py') dump(fp, frozenmain, 'test_frozenmain') print(f"{filename} written") if __name__ == "__main__": main() |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |