SILENT KILLERPanel

Current Path: > > usr > lib64 > python3.8 > lib2to3 > fixes


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //usr/lib64/python3.8/lib2to3/fixes

NameTypeSizeLast ModifiedActions
__pycache__ Directory - -
__init__.py File 47 bytes June 06 2023 13:32:21.
fix_apply.py File 2346 bytes June 06 2023 13:32:21.
fix_asserts.py File 984 bytes June 06 2023 13:32:21.
fix_basestring.py File 320 bytes June 06 2023 13:32:21.
fix_buffer.py File 590 bytes June 06 2023 13:32:21.
fix_dict.py File 3760 bytes June 06 2023 13:32:21.
fix_except.py File 3344 bytes June 06 2023 13:32:21.
fix_exec.py File 979 bytes June 06 2023 13:32:21.
fix_execfile.py File 2048 bytes June 06 2023 13:32:21.
fix_exitfunc.py File 2495 bytes June 06 2023 13:32:21.
fix_filter.py File 2765 bytes June 06 2023 13:32:21.
fix_funcattrs.py File 644 bytes June 06 2023 13:32:21.
fix_future.py File 547 bytes June 06 2023 13:32:21.
fix_getcwdu.py File 451 bytes June 06 2023 13:32:21.
fix_has_key.py File 3196 bytes June 06 2023 13:32:21.
fix_idioms.py File 4876 bytes June 06 2023 13:32:21.
fix_import.py File 3256 bytes June 06 2023 13:32:21.
fix_imports.py File 5684 bytes June 06 2023 13:32:21.
fix_imports2.py File 289 bytes June 06 2023 13:32:21.
fix_input.py File 708 bytes June 06 2023 13:32:21.
fix_intern.py File 1144 bytes June 06 2023 13:32:21.
fix_isinstance.py File 1608 bytes June 06 2023 13:32:21.
fix_itertools.py File 1548 bytes June 06 2023 13:32:21.
fix_itertools_imports.py File 2086 bytes June 06 2023 13:32:21.
fix_long.py File 476 bytes June 06 2023 13:32:21.
fix_map.py File 3640 bytes June 06 2023 13:32:21.
fix_metaclass.py File 8196 bytes June 06 2023 13:32:21.
fix_methodattrs.py File 606 bytes June 06 2023 13:32:21.
fix_ne.py File 571 bytes June 06 2023 13:32:21.
fix_next.py File 3174 bytes June 06 2023 13:32:21.
fix_nonzero.py File 591 bytes June 06 2023 13:32:21.
fix_numliterals.py File 768 bytes June 06 2023 13:32:21.
fix_operator.py File 3426 bytes June 06 2023 13:32:21.
fix_paren.py File 1227 bytes June 06 2023 13:32:21.
fix_print.py File 2844 bytes June 06 2023 13:32:21.
fix_raise.py File 2926 bytes June 06 2023 13:32:21.
fix_raw_input.py File 454 bytes June 06 2023 13:32:21.
fix_reduce.py File 837 bytes June 06 2023 13:32:21.
fix_reload.py File 1081 bytes June 06 2023 13:32:21.
fix_renames.py File 2221 bytes June 06 2023 13:32:21.
fix_repr.py File 613 bytes June 06 2023 13:32:21.
fix_set_literal.py File 1697 bytes June 06 2023 13:32:21.
fix_standarderror.py File 449 bytes June 06 2023 13:32:21.
fix_sys_exc.py File 1034 bytes June 06 2023 13:32:21.
fix_throw.py File 1582 bytes June 06 2023 13:32:21.
fix_tuple_params.py File 5565 bytes June 06 2023 13:32:21.
fix_types.py File 1774 bytes June 06 2023 13:32:21.
fix_unicode.py File 1256 bytes June 06 2023 13:32:21.
fix_urllib.py File 8353 bytes June 06 2023 13:32:21.
fix_ws_comma.py File 1090 bytes June 06 2023 13:32:21.
fix_xrange.py File 2694 bytes June 06 2023 13:32:21.
fix_xreadlines.py File 689 bytes June 06 2023 13:32:21.
fix_zip.py File 1289 bytes June 06 2023 13:32:21.

Reading File: //usr/lib64/python3.8/lib2to3/fixes/fix_map.py

# Copyright 2007 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.

"""Fixer that changes map(F, ...) into list(map(F, ...)) unless there
exists a 'from future_builtins import map' statement in the top-level
namespace.

As a special case, map(None, X) is changed into list(X).  (This is
necessary because the semantics are changed in this case -- the new
map(None, X) is equivalent to [(x,) for x in X].)

We avoid the transformation (except for the special case mentioned
above) if the map() call is directly contained in iter(<>), list(<>),
tuple(<>), sorted(<>), ...join(<>), or for V in <>:.

NOTE: This is still not correct if the original code was depending on
map(F, X, Y, ...) to go on until the longest argument is exhausted,
substituting None for missing values -- like zip(), it now stops as
soon as the shortest argument is exhausted.
"""

# Local imports
from ..pgen2 import token
from .. import fixer_base
from ..fixer_util import Name, ArgList, Call, ListComp, in_special_context
from ..pygram import python_symbols as syms
from ..pytree import Node


class FixMap(fixer_base.ConditionalFix):
    BM_compatible = True

    PATTERN = """
    map_none=power<
        'map'
        trailer< '(' arglist< 'None' ',' arg=any [','] > ')' >
        [extra_trailers=trailer*]
    >
    |
    map_lambda=power<
        'map'
        trailer<
            '('
            arglist<
                lambdef< 'lambda'
                         (fp=NAME | vfpdef< '(' fp=NAME ')'> ) ':' xp=any
                >
                ','
                it=any
            >
            ')'
        >
        [extra_trailers=trailer*]
    >
    |
    power<
        'map' args=trailer< '(' [any] ')' >
        [extra_trailers=trailer*]
    >
    """

    skip_on = 'future_builtins.map'

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

        trailers = []
        if 'extra_trailers' in results:
            for t in results['extra_trailers']:
                trailers.append(t.clone())

        if node.parent.type == syms.simple_stmt:
            self.warning(node, "You should use a for loop here")
            new = node.clone()
            new.prefix = ""
            new = Call(Name("list"), [new])
        elif "map_lambda" in results:
            new = ListComp(results["xp"].clone(),
                           results["fp"].clone(),
                           results["it"].clone())
            new = Node(syms.power, [new] + trailers, prefix="")

        else:
            if "map_none" in results:
                new = results["arg"].clone()
                new.prefix = ""
            else:
                if "args" in results:
                    args = results["args"]
                    if args.type == syms.trailer and \
                       args.children[1].type == syms.arglist and \
                       args.children[1].children[0].type == token.NAME and \
                       args.children[1].children[0].value == "None":
                        self.warning(node, "cannot convert map(None, ...) "
                                     "with multiple arguments because map() "
                                     "now truncates to the shortest sequence")
                        return

                    new = Node(syms.power, [Name("map"), args.clone()])
                    new.prefix = ""

                if in_special_context(node):
                    return None

            new = Node(syms.power, [Name("list"), ArgList([new])] + trailers)
            new.prefix = ""

        new.prefix = node.prefix
        return new

SILENT KILLER Tool