# Path: py3kwarn2to3/fixer_util.py
# def Name(name, prefix=None):
#     """Return a NAME leaf"""
#     return Leaf(token.NAME, name, prefix=prefix)
# 
# def Call(func_name, args=None, prefix=None):
#     """A function call"""
#     node = Node(syms.power, [func_name, ArgList(args)])
#     if prefix is not None:
#         node.prefix = prefix
#     return node
# 
# def ListComp(xp, fp, it, test=None):
#     """A list comprehension of the form [xp for fp in it if test].
# 
#     If test is None, the "if test" part is omitted.
#     """
#     xp.prefix = u""
#     fp.prefix = u" "
#     it.prefix = u" "
#     for_leaf = Leaf(token.NAME, u"for")
#     for_leaf.prefix = u" "
#     in_leaf = Leaf(token.NAME, u"in")
#     in_leaf.prefix = u" "
#     inner_args = [for_leaf, fp, in_leaf, it]
#     if test:
#         test.prefix = u" "
#         if_leaf = Leaf(token.NAME, u"if")
#         if_leaf.prefix = u" "
#         inner_args.append(Node(syms.comp_if, [if_leaf, test]))
#     inner = Node(syms.listmaker, [xp, Node(syms.comp_for, inner_args)])
#     return Node(syms.atom,
#                        [Leaf(token.LBRACE, u"["),
#                         inner,
#                         Leaf(token.RBRACE, u"]")])
# 
# def in_special_context(node):
#     """ Returns true if node is in an environment where all that is required
#         of it is being itterable (ie, it doesn't matter if it returns a list
#         or an itterator).
#         See test_map_nochange in test_fixers.py for some examples and tests.
#         """
#     global p0, p1, p2, pats_built
#     if not pats_built:
#         p1 = patcomp.compile_pattern(p1)
#         p0 = patcomp.compile_pattern(p0)
#         p2 = patcomp.compile_pattern(p2)
#         pats_built = True
#     patterns = [p0, p1, p2]
#     for pattern, parent in zip(patterns, attr_chain(node, "parent")):
#         results = {}
#         if pattern.match(parent, results) and results["node"] is node:
#             return True
#     return False


from .. import fixer_base
from ..fixer_util import Name, Call, ListComp, in_special_context
                it=any
            >
            ')'
        >
    >
    |
    power<
        'filter'
        trailer< '(' arglist< none='None' ',' seq=any > ')' >
    >
    |
    power<
        'filter'
        args=trailer< '(' [any] ')' >
    >
    """

    skip_on = "future_builtins.filter"

    def transform(self, node, results):
        if self.should_skip(node):
            return

        if "filter_lambda" in results:
            new = ListComp(results.get("fp").clone(),
                           results.get("fp").clone(),
                           results.get("it").clone(),
                           results.get("xp").clone())

        elif "none" in results:

# Path: py3kwarn2to3/fixer_util.py
# def Name(name, prefix=None):
#     """Return a NAME leaf"""
#     return Leaf(token.NAME, name, prefix=prefix)
# 
# def Call(func_name, args=None, prefix=None):
#     """A function call"""
#     node = Node(syms.power, [func_name, ArgList(args)])
#     if prefix is not None:
#         node.prefix = prefix
#     return node
# 
# def ListComp(xp, fp, it, test=None):
#     """A list comprehension of the form [xp for fp in it if test].
# 
#     If test is None, the "if test" part is omitted.
#     """
#     xp.prefix = u""
#     fp.prefix = u" "
#     it.prefix = u" "
#     for_leaf = Leaf(token.NAME, u"for")
#     for_leaf.prefix = u" "
#     in_leaf = Leaf(token.NAME, u"in")
#     in_leaf.prefix = u" "
#     inner_args = [for_leaf, fp, in_leaf, it]
#     if test:
#         test.prefix = u" "
#         if_leaf = Leaf(token.NAME, u"if")
#         if_leaf.prefix = u" "
#         inner_args.append(Node(syms.comp_if, [if_leaf, test]))
#     inner = Node(syms.listmaker, [xp, Node(syms.comp_for, inner_args)])
#     return Node(syms.atom,
#                        [Leaf(token.LBRACE, u"["),
#                         inner,
#                         Leaf(token.RBRACE, u"]")])
# 
# def in_special_context(node):
#     """ Returns true if node is in an environment where all that is required
#         of it is being itterable (ie, it doesn't matter if it returns a list
#         or an itterator).
#         See test_map_nochange in test_fixers.py for some examples and tests.
#         """
#     global p0, p1, p2, pats_built
#     if not pats_built:
#         p1 = patcomp.compile_pattern(p1)
#         p0 = patcomp.compile_pattern(p0)
#         p2 = patcomp.compile_pattern(p2)
#         pats_built = True
#     patterns = [p0, p1, p2]
#     for pattern, parent in zip(patterns, attr_chain(node, "parent")):
#         results = {}
#         if pattern.match(parent, results) and results["node"] is node:
#             return True
#     return False


# Path: py3kwarn2to3/fixes/fix_filter.py
from .. import fixer_base
from ..fixer_util import Name, Call, ListComp, in_special_context

                it=any
            >
            ')'
        >
    >
    |
    power<
        'filter'
        trailer< '(' arglist< none='None' ',' seq=any > ')' >
    >
    |
    power<
        'filter'
        args=trailer< '(' [any] ')' >
    >
    """

    skip_on = "future_builtins.filter"

    def transform(self, node, results):
        if self.should_skip(node):
            return

        if "filter_lambda" in results:
            new = ListComp(results.get("fp").clone(),
                           results.get("fp").clone(),
                           results.get("it").clone(),
                           results.get("xp").clone())

        elif "none" in results:

            new = ListComp(Name(u"_f"),