GRAYBYTE WORDPRESS FILE MANAGER1460

Server IP : 198.54.121.189 / Your IP : 216.73.216.224
System : Linux premium69.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
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /opt/cloudlinux/venv/lib/python3.11/site-packages/astroid/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /opt/cloudlinux/venv/lib/python3.11/site-packages/astroid//transforms.py
# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
# For details: https://github.com/PyCQA/astroid/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt

from __future__ import annotations

import collections
from typing import TYPE_CHECKING

from astroid.context import _invalidate_cache

if TYPE_CHECKING:
    from astroid import NodeNG


class TransformVisitor:
    """A visitor for handling transforms.

    The standard approach of using it is to call
    :meth:`~visit` with an *astroid* module and the class
    will take care of the rest, walking the tree and running the
    transforms for each encountered node.

    Based on its usage in AstroidManager.brain, it should not be reinstantiated.
    """

    def __init__(self):
        self.transforms = collections.defaultdict(list)

    def _transform(self, node: NodeNG) -> NodeNG:
        """Call matching transforms for the given node if any and return the
        transformed node.
        """
        cls = node.__class__

        transforms = self.transforms[cls]
        for transform_func, predicate in transforms:
            if predicate is None or predicate(node):
                ret = transform_func(node)
                # if the transformation function returns something, it's
                # expected to be a replacement for the node
                if ret is not None:
                    _invalidate_cache()
                    node = ret
                if ret.__class__ != cls:
                    # Can no longer apply the rest of the transforms.
                    break
        return node

    def _visit(self, node):
        if hasattr(node, "_astroid_fields"):
            for name in node._astroid_fields:
                value = getattr(node, name)
                visited = self._visit_generic(value)
                if visited != value:
                    setattr(node, name, visited)
        return self._transform(node)

    def _visit_generic(self, node):
        if isinstance(node, list):
            return [self._visit_generic(child) for child in node]
        if isinstance(node, tuple):
            return tuple(self._visit_generic(child) for child in node)
        if not node or isinstance(node, str):
            return node

        return self._visit(node)

    def register_transform(self, node_class, transform, predicate=None) -> None:
        """Register `transform(node)` function to be applied on the given
        astroid's `node_class` if `predicate` is None or returns true
        when called with the node as argument.

        The transform function may return a value which is then used to
        substitute the original node in the tree.
        """
        self.transforms[node_class].append((transform, predicate))

    def unregister_transform(self, node_class, transform, predicate=None) -> None:
        """Unregister the given transform."""
        self.transforms[node_class].remove((transform, predicate))

    def visit(self, module):
        """Walk the given astroid *tree* and transform each encountered node.

        Only the nodes which have transforms registered will actually
        be replaced or changed.
        """
        return self._visit(module)

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
June 25 2025 08:31:36
root / root
0755
__pycache__
--
May 15 2025 08:30:33
root / root
0755
brain
--
May 15 2025 08:30:33
root / root
0755
interpreter
--
May 15 2025 08:30:33
root / root
0755
nodes
--
May 15 2025 08:30:33
root / root
0755
__init__.py
4.984 KB
April 17 2025 13:10:59
root / root
0644
__pkginfo__.py
0.268 KB
April 17 2025 13:10:59
root / root
0644
_ast.py
4.049 KB
April 17 2025 13:10:59
root / root
0644
_backport_stdlib_names.py
6.852 KB
April 17 2025 13:10:59
root / root
0644
_cache.py
0.768 KB
April 17 2025 13:10:59
root / root
0644
arguments.py
12.654 KB
April 17 2025 13:10:59
root / root
0644
astroid_manager.py
0.559 KB
April 17 2025 13:10:59
root / root
0644
bases.py
24.994 KB
April 17 2025 13:10:59
root / root
0644
builder.py
18.348 KB
April 17 2025 13:10:59
root / root
0644
const.py
1.069 KB
April 17 2025 13:10:59
root / root
0644
constraint.py
4.925 KB
April 17 2025 13:10:59
root / root
0644
context.py
5.854 KB
April 17 2025 13:10:59
root / root
0644
decorators.py
9.854 KB
April 17 2025 13:10:59
root / root
0644
exceptions.py
12.782 KB
April 17 2025 13:10:59
root / root
0644
filter_statements.py
9.417 KB
April 17 2025 13:10:59
root / root
0644
helpers.py
11.07 KB
April 17 2025 13:10:59
root / root
0644
inference.py
44.063 KB
April 17 2025 13:10:59
root / root
0644
inference_tip.py
2.82 KB
April 17 2025 13:10:59
root / root
0644
manager.py
17.539 KB
April 17 2025 13:10:59
root / root
0644
mixins.py
1.154 KB
April 17 2025 13:10:59
root / root
0644
modutils.py
22.957 KB
April 17 2025 13:10:59
root / root
0644
node_classes.py
1.797 KB
April 17 2025 13:10:59
root / root
0644
objects.py
12.458 KB
April 17 2025 13:10:59
root / root
0644
protocols.py
32.203 KB
April 17 2025 13:10:59
root / root
0644
raw_building.py
22.339 KB
April 17 2025 13:10:59
root / root
0644
rebuilder.py
77.862 KB
April 17 2025 13:10:59
root / root
0644
scoped_nodes.py
0.936 KB
April 17 2025 13:10:59
root / root
0644
test_utils.py
2.377 KB
April 17 2025 13:10:59
root / root
0644
transforms.py
3.194 KB
April 17 2025 13:10:59
root / root
0644
typing.py
1.937 KB
April 17 2025 13:10:59
root / root
0644
util.py
4.618 KB
April 17 2025 13:10:59
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF