You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Admnistrivia
revise add-test.py
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user