You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Small pyflakes stuff
This commit is contained in:
@@ -21,10 +21,9 @@ Step 2: Run the test:
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from uncompyle6 import main, verify, PYTHON3
|
||||
from uncompyle6 import main, PYTHON3
|
||||
import os, time, shutil
|
||||
from fnmatch import fnmatch
|
||||
import glob
|
||||
|
||||
#----- configure this for your needs
|
||||
|
||||
@@ -101,7 +100,7 @@ def do_tests(src_dir, patterns, target_dir, start_with=None, do_verify=False):
|
||||
if __name__ == '__main__':
|
||||
import getopt, sys
|
||||
|
||||
do_verify = 0
|
||||
do_verify = False
|
||||
test_dirs = []
|
||||
start_with = None
|
||||
|
||||
@@ -112,7 +111,7 @@ if __name__ == '__main__':
|
||||
+ test_options_keys )
|
||||
for opt, val in opts:
|
||||
if opt == '--verify':
|
||||
do_verify = 1
|
||||
do_verify = True
|
||||
elif opt == '--start-with':
|
||||
start_with = val
|
||||
elif opt[2:] in test_options_keys:
|
||||
|
@@ -26,8 +26,6 @@
|
||||
Probably a complete rewrite would be sensefull. hG/2000-12-27
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
|
||||
__docformat__ = 'restructuredtext'
|
||||
@@ -45,13 +43,6 @@ IS_PYPY = '__pypy__' in sys.builtin_module_names
|
||||
|
||||
sys.setrecursionlimit(5000)
|
||||
|
||||
def check_python_version(program):
|
||||
if not (sys.version_info[0:2] in ((2, 6), (2, 7), (3, 2), (3, 3), (3, 4), (3, 5))):
|
||||
print('Error: %s requires Python 2.6, 2.7, 3.2, 3.3, 3.4 or 3.5' % program,
|
||||
file=sys.stderr)
|
||||
sys.exit(-1)
|
||||
return
|
||||
|
||||
import uncompyle6.semantics.pysource
|
||||
import uncompyle6.semantics.fragments
|
||||
import uncompyle6.load
|
||||
|
@@ -37,8 +37,6 @@ Type -h for for full help.""" % program
|
||||
|
||||
check_python_version(program)
|
||||
|
||||
outfile = '-'
|
||||
out_base = None
|
||||
use_uncompyle6_format = False
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
|
@@ -66,7 +66,7 @@ def usage():
|
||||
def main_bin():
|
||||
check_python_version(program)
|
||||
|
||||
showasm = showast = do_verify = recurse_dirs = False
|
||||
showast = do_verify = recurse_dirs = False
|
||||
numproc = 0
|
||||
outfile = '-'
|
||||
out_base = None
|
||||
|
@@ -226,75 +226,6 @@ def get_instructions(x, opnames, first_line=None):
|
||||
co.co_consts, cell_names, linestarts,
|
||||
line_offset)
|
||||
|
||||
def _get_instructions_bytes(code, opnames, varnames=None, names=None, constants=None,
|
||||
cells=None, linestarts=None, line_offset=0):
|
||||
"""Iterate over the instructions in a bytecode string.
|
||||
|
||||
Generates a sequence of Instruction namedtuples giving the details of each
|
||||
opcode. Additional information about the code's runtime environment
|
||||
(e.g. variable names, constants) can be specified using optional
|
||||
arguments.
|
||||
|
||||
"""
|
||||
labels = findlabels(code)
|
||||
extended_arg = 0
|
||||
starts_line = None
|
||||
# enumerate() is not an option, since we sometimes process
|
||||
# multiple elements on a single pass through the loop
|
||||
n = len(code)
|
||||
i = 0
|
||||
while i < n:
|
||||
op = code[i]
|
||||
if isinstance(op, str):
|
||||
op_num = ord(op)
|
||||
else:
|
||||
op_num = op
|
||||
|
||||
offset = i
|
||||
if linestarts is not None:
|
||||
starts_line = linestarts.get(i, None)
|
||||
if starts_line is not None:
|
||||
starts_line += line_offset
|
||||
is_jump_target = i in labels
|
||||
i = i+1
|
||||
arg = None
|
||||
argval = None
|
||||
argrepr = ''
|
||||
if op >= HAVE_ARGUMENT:
|
||||
if isinstance(code[i], str):
|
||||
arg = op_num + ord(code[i+1])*256 + extended_arg
|
||||
else:
|
||||
arg = code[i] + code[i+1]*256 + extended_arg
|
||||
extended_arg = 0
|
||||
i = i+2
|
||||
if op == EXTENDED_ARG:
|
||||
extended_arg = arg*65536
|
||||
# Set argval to the dereferenced value of the argument when
|
||||
# availabe, and argrepr to the string representation of argval.
|
||||
# _disassemble_bytes needs the string repr of the
|
||||
# raw name index for LOAD_GLOBAL, LOAD_CONST, etc.
|
||||
argval = arg
|
||||
if op in hasconst:
|
||||
argval, argrepr = _get_const_info(arg, constants)
|
||||
elif op in hasname:
|
||||
argval, argrepr = _get_name_info(arg, names)
|
||||
elif op in hasjrel:
|
||||
argval = i + arg
|
||||
argrepr = "to " + repr(argval)
|
||||
elif op in haslocal:
|
||||
argval, argrepr = _get_name_info(arg, varnames)
|
||||
elif op in hascompare:
|
||||
argval = cmp_op[arg]
|
||||
argrepr = argval
|
||||
elif op in hasfree:
|
||||
argval, argrepr = _get_name_info(arg, cells)
|
||||
elif op in hasnargs:
|
||||
argrepr = ("%d positional, %d keyword pair, %d annotated" %
|
||||
(code[i-2], code[i-1], code[i]))
|
||||
yield Instruction(opnames[op_num], op,
|
||||
arg, argval, argrepr,
|
||||
offset, starts_line, is_jump_target)
|
||||
|
||||
def _get_const_info(const_index, const_list):
|
||||
"""Helper to get optional details about const references
|
||||
|
||||
|
@@ -49,8 +49,6 @@ else:
|
||||
from spark_parser import GenericASTTraversal, GenericASTTraversalPruningException, \
|
||||
DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
||||
|
||||
from types import CodeType
|
||||
|
||||
from collections import namedtuple
|
||||
NodeInfo = namedtuple("NodeInfo", "node start finish")
|
||||
ExtractInfo = namedtuple("ExtractInfo",
|
||||
@@ -1359,11 +1357,10 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
args_node = node[-1]
|
||||
if isinstance(args_node.attr, tuple):
|
||||
defparams = node[:args_node.attr[0]]
|
||||
pos_args, kw_args, annotate_args = args_node.attr
|
||||
kw_args, annotate_args = args_node.attr
|
||||
else:
|
||||
defparams = node[:args_node.attr]
|
||||
kw_args, annotate_args = (0, 0)
|
||||
pos_args = args_node.attr
|
||||
kw_args = (0, 0)
|
||||
pass
|
||||
|
||||
code = node[code_index].attr
|
||||
@@ -1527,7 +1524,6 @@ if __name__ == '__main__':
|
||||
return fn.__code__
|
||||
|
||||
def gcd(a, b):
|
||||
from os import path
|
||||
if a > b:
|
||||
(a, b) = (b, a)
|
||||
pass
|
||||
|
@@ -8,7 +8,7 @@ byte-code verification
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import dis, inspect, operator
|
||||
import dis, operator
|
||||
|
||||
import uncompyle6
|
||||
import uncompyle6.scanner as scanner
|
||||
|
Reference in New Issue
Block a user