Admnistrivia

revise add-test.py
This commit is contained in:
rocky
2021-11-24 15:12:53 -05:00
parent 2c4acecc9d
commit 03a71290e9

View File

@@ -1,14 +1,16 @@
#!/usr/bin/env python
""" Trivial helper program to bytecompile and run an uncompile
""" Trivial helper program to byte compile and run an uncompyle6 on the bytecode file.
"""
import os, sys, py_compile
from xdis.version_info import version_tuple_to_str, PYTHON_VERSION_TRIPLE
assert (2 <= len(sys.argv) <= 4)
version = sys.version[0:3]
vers = sys.version_info[:2]
if len(sys.argv) < 2:
print("Usage: add-test.py [--run] *python-source*... [optimize-level]")
sys.exit(1)
if sys.argv[1] in ("--run", "-r"):
suffix = "_run"
assert sys.argv >= 3
py_source = sys.argv[2:]
i = 2
else:
@@ -17,7 +19,10 @@ else:
i = 1
try:
optimize = int(sys.argv[-1])
assert sys.argv >= i + 2
py_source = sys.argv[i:-1]
i = 2
except:
optimize = 2
@@ -31,8 +36,7 @@ for path in py_source:
bytecode = "bytecode_%s%s/%s.pyc" % (version, suffix, short)
print("byte-compiling %s to %s" % (path, bytecode))
py_compile.compile(path, bytecode, optimize=optimize)
if vers > (3, 1):
if PYTHON_VERSION_TRIPLE >= (3, 2):
py_compile.compile(path, bytecode, optimize=optimize)
else:
py_compile.compile(path, bytecode)