GRAYBYTE WORDPRESS FILE MANAGER1330

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
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/alt/python27/lib64/python2.7/compiler/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /opt/alt/python27/lib64/python2.7/compiler//visitor.py
from compiler import ast

# XXX should probably rename ASTVisitor to ASTWalker
# XXX can it be made even more generic?

class ASTVisitor:
    """Performs a depth-first walk of the AST

    The ASTVisitor will walk the AST, performing either a preorder or
    postorder traversal depending on which method is called.

    methods:
    preorder(tree, visitor)
    postorder(tree, visitor)
        tree: an instance of ast.Node
        visitor: an instance with visitXXX methods

    The ASTVisitor is responsible for walking over the tree in the
    correct order.  For each node, it checks the visitor argument for
    a method named 'visitNodeType' where NodeType is the name of the
    node's class, e.g. Class.  If the method exists, it is called
    with the node as its sole argument.

    The visitor method for a particular node type can control how
    child nodes are visited during a preorder walk.  (It can't control
    the order during a postorder walk, because it is called _after_
    the walk has occurred.)  The ASTVisitor modifies the visitor
    argument by adding a visit method to the visitor; this method can
    be used to visit a child node of arbitrary type.
    """

    VERBOSE = 0

    def __init__(self):
        self.node = None
        self._cache = {}

    def default(self, node, *args):
        for child in node.getChildNodes():
            self.dispatch(child, *args)

    def dispatch(self, node, *args):
        self.node = node
        klass = node.__class__
        meth = self._cache.get(klass, None)
        if meth is None:
            className = klass.__name__
            meth = getattr(self.visitor, 'visit' + className, self.default)
            self._cache[klass] = meth
##        if self.VERBOSE > 0:
##            className = klass.__name__
##            if self.VERBOSE == 1:
##                if meth == 0:
##                    print "dispatch", className
##            else:
##                print "dispatch", className, (meth and meth.__name__ or '')
        return meth(node, *args)

    def preorder(self, tree, visitor, *args):
        """Do preorder walk of tree using visitor"""
        self.visitor = visitor
        visitor.visit = self.dispatch
        self.dispatch(tree, *args) # XXX *args make sense?

class ExampleASTVisitor(ASTVisitor):
    """Prints examples of the nodes that aren't visited

    This visitor-driver is only useful for development, when it's
    helpful to develop a visitor incrementally, and get feedback on what
    you still have to do.
    """
    examples = {}

    def dispatch(self, node, *args):
        self.node = node
        meth = self._cache.get(node.__class__, None)
        className = node.__class__.__name__
        if meth is None:
            meth = getattr(self.visitor, 'visit' + className, 0)
            self._cache[node.__class__] = meth
        if self.VERBOSE > 1:
            print "dispatch", className, (meth and meth.__name__ or '')
        if meth:
            meth(node, *args)
        elif self.VERBOSE > 0:
            klass = node.__class__
            if klass not in self.examples:
                self.examples[klass] = klass
                print
                print self.visitor
                print klass
                for attr in dir(node):
                    if attr[0] != '_':
                        print "\t", "%-12.12s" % attr, getattr(node, attr)
                print
            return self.default(node, *args)

# XXX this is an API change

_walker = ASTVisitor
def walk(tree, visitor, walker=None, verbose=None):
    if walker is None:
        walker = _walker()
    if verbose is not None:
        walker.VERBOSE = verbose
    walker.preorder(tree, visitor)
    return walker.visitor

def dumpNode(node):
    print node.__class__
    for attr in dir(node):
        if attr[0] != '_':
            print "\t", "%-10.10s" % attr, getattr(node, attr)

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
January 24 2025 09:34:02
root / linksafe
0755
__init__.py
0.999 KB
January 08 2025 10:43:00
root / linksafe
0644
__init__.pyc
1.279 KB
January 08 2025 10:43:01
root / linksafe
0644
__init__.pyo
1.279 KB
January 08 2025 10:43:01
root / linksafe
0644
ast.py
36.629 KB
January 08 2025 10:43:01
root / linksafe
0644
ast.pyc
75.373 KB
January 08 2025 10:43:00
root / linksafe
0644
ast.pyo
75.373 KB
January 08 2025 10:43:00
root / linksafe
0644
consts.py
0.457 KB
January 08 2025 10:43:00
root / linksafe
0644
consts.pyc
0.732 KB
January 08 2025 10:43:00
root / linksafe
0644
consts.pyo
0.732 KB
January 08 2025 10:43:00
root / linksafe
0644
future.py
1.849 KB
January 08 2025 10:43:01
root / linksafe
0644
future.pyc
3.014 KB
January 08 2025 10:43:00
root / linksafe
0644
future.pyo
3.014 KB
January 08 2025 10:43:00
root / linksafe
0644
misc.py
1.752 KB
January 08 2025 10:43:01
root / linksafe
0644
misc.pyc
3.887 KB
January 08 2025 10:43:01
root / linksafe
0644
misc.pyo
3.887 KB
January 08 2025 10:43:01
root / linksafe
0644
pyassem.py
23.699 KB
January 08 2025 10:43:00
root / linksafe
0644
pyassem.pyc
26.358 KB
January 08 2025 10:43:01
root / linksafe
0644
pyassem.pyo
25.798 KB
January 08 2025 10:43:01
root / linksafe
0644
pycodegen.py
46.688 KB
January 08 2025 10:43:01
root / linksafe
0644
pycodegen.pyc
57.387 KB
January 08 2025 10:43:01
root / linksafe
0644
pycodegen.pyo
56.953 KB
January 08 2025 10:43:00
root / linksafe
0644
symbols.py
14.149 KB
January 08 2025 10:43:01
root / linksafe
0644
symbols.pyc
17.974 KB
January 08 2025 10:43:00
root / linksafe
0644
symbols.pyo
17.94 KB
January 08 2025 10:43:01
root / linksafe
0644
syntax.py
1.41 KB
January 08 2025 10:43:00
root / linksafe
0644
syntax.pyc
1.914 KB
January 08 2025 10:43:01
root / linksafe
0644
syntax.pyo
1.914 KB
January 08 2025 10:43:01
root / linksafe
0644
transformer.py
51.871 KB
January 08 2025 10:43:01
root / linksafe
0644
transformer.pyc
48.115 KB
January 08 2025 10:43:01
root / linksafe
0644
transformer.pyo
46.343 KB
January 08 2025 10:43:01
root / linksafe
0644
visitor.py
3.805 KB
January 08 2025 10:43:01
root / linksafe
0644
visitor.pyc
4.216 KB
January 08 2025 10:43:01
root / linksafe
0644
visitor.pyo
4.216 KB
January 08 2025 10:43:01
root / linksafe
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF