Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3..../lib2to3/fixes
File: fix_zip.py
"""
[0] Fix | Delete
Fixer that changes zip(seq0, seq1, ...) into list(zip(seq0, seq1, ...)
[1] Fix | Delete
unless there exists a 'from future_builtins import zip' statement in the
[2] Fix | Delete
top-level namespace.
[3] Fix | Delete
[4] Fix | Delete
We avoid the transformation if the zip() call is directly contained in
[5] Fix | Delete
iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or for V in <>:.
[6] Fix | Delete
"""
[7] Fix | Delete
[8] Fix | Delete
# Local imports
[9] Fix | Delete
from .. import fixer_base
[10] Fix | Delete
from ..pytree import Node
[11] Fix | Delete
from ..pygram import python_symbols as syms
[12] Fix | Delete
from ..fixer_util import Name, ArgList, in_special_context
[13] Fix | Delete
[14] Fix | Delete
[15] Fix | Delete
class FixZip(fixer_base.ConditionalFix):
[16] Fix | Delete
[17] Fix | Delete
BM_compatible = True
[18] Fix | Delete
PATTERN = """
[19] Fix | Delete
power< 'zip' args=trailer< '(' [any] ')' > [trailers=trailer*]
[20] Fix | Delete
>
[21] Fix | Delete
"""
[22] Fix | Delete
[23] Fix | Delete
skip_on = "future_builtins.zip"
[24] Fix | Delete
[25] Fix | Delete
def transform(self, node, results):
[26] Fix | Delete
if self.should_skip(node):
[27] Fix | Delete
return
[28] Fix | Delete
[29] Fix | Delete
if in_special_context(node):
[30] Fix | Delete
return None
[31] Fix | Delete
[32] Fix | Delete
args = results['args'].clone()
[33] Fix | Delete
args.prefix = ""
[34] Fix | Delete
[35] Fix | Delete
trailers = []
[36] Fix | Delete
if 'trailers' in results:
[37] Fix | Delete
trailers = [n.clone() for n in results['trailers']]
[38] Fix | Delete
for n in trailers:
[39] Fix | Delete
n.prefix = ""
[40] Fix | Delete
[41] Fix | Delete
new = Node(syms.power, [Name("zip"), args], prefix="")
[42] Fix | Delete
new = Node(syms.power, [Name("list"), ArgList([new])] + trailers)
[43] Fix | Delete
new.prefix = node.prefix
[44] Fix | Delete
return new
[45] Fix | Delete
[46] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function