Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(0)  |  Derive(0)  |  Import(2)
Dumps an AST or similar structure:

- Pretty-prints with indentation
- Doesn't print line/column/ctx info

        def dump(node, name=None, initial_indent='', indentation='    ',
         maxline=120, maxmerged=80, iter_node=iter_node, special=ast.AST,
         list=list, isinstance=isinstance, type=type, len=len):
    """Dumps an AST or similar structure:

       - Pretty-prints with indentation
       - Doesn't print line/column/ctx info

    """
    def dump(node, name=None, indent=''):
        level = indent + indentation
        name = name and name + '=' or ''
        values = list(iter_node(node))
        if isinstance(node, list):
            prefix, suffix = '%s[' % name, ']'
        elif values:
            prefix, suffix = '%s%s(' % (name, type(node).__name__), ')'
        elif isinstance(node, special):
            prefix, suffix = name + type(node).__name__, ''
        else:
            return '%s%s' % (name, repr(node))
        node = [dump(a, b, level) for a, b in values if b != 'ctx']
        oneline = '%s%s%s' % (prefix, ', '.join(node), suffix)
        if len(oneline) + len(indent) < maxline:
            return '%s' % oneline
        if node and len(prefix) + len(node[0]) < maxmerged:
            prefix = '%s%s,' % (prefix, node.pop(0))
        node = (',\n%s' % level).join(node).lstrip()
        return '%s\n%s%s%s' % (prefix, level, node, suffix)
    return dump(node, name, initial_indent)
        


src/a/s/astor-0.3/astor/__init__.py   astor(Download)
__version__ = '0.3'
 
from astor.misc import iter_node, dump, all_symbols, get_anyop
from astor.misc import get_boolop, get_binop, get_cmpop, get_unaryop
from astor.misc import ExplicitNodeVisitor

src/a/s/astor-HEAD/astor/__init__.py   astor(Download)
__version__ = '0.4-dev'
 
from astor.misc import iter_node, dump, all_symbols, get_anyop
from astor.misc import get_boolop, get_binop, get_cmpop, get_unaryop
from astor.misc import ExplicitNodeVisitor