Part of the astor library for Python AST manipulation. License: 3-clause BSD Copyright 2012-2015 (c) Patrick Maupin Copyright 2013-2015 (c) Berker Peksag Utilities for node (and, by extension, tree) manipulation. For a whole-tree approach, see the treewalk submodule.
Class |
|
This expands on the ast module's NodeVisitor class to remove any implicit visits. |
Class |
|
This is not the class you are looking for. |
Function | allow |
This ugly little monkey-patcher adds in a helper class to all the AST node types. This helper class allows eq/ne comparisons to work, so that entire trees can be easily compared by Python's comparison machinery... |
Function | dump |
Dumps an AST or similar structure: |
Function | fast |
This is optimized to compare two AST trees for equality. It makes several assumptions that are currently true for AST trees used by rtrip, and it doesn't examine the _attributes. |
Function | iter |
Iterates over an object: |
Function | strip |
Strips an AST by removing all attributes not in _fields. |
This ugly little monkey-patcher adds in a helper class to all the AST node types. This helper class allows eq/ne comparisons to work, so that entire trees can be easily compared by Python's comparison machinery. Used by the anti8 functions to compare old and new ASTs. Could also be used by the test library.
Dumps an AST or similar structure: - Pretty-prints with indentation - Doesn't print line/column/ctx info
This is optimized to compare two AST trees for equality. It makes several assumptions that are currently true for AST trees used by rtrip, and it doesn't examine the _attributes.
Iterates over an object: - If the object has a _fields attribute, it gets attributes in the order of this and returns name, value pairs. - Otherwise, if the object is a list instance, it returns name, value pairs for each item in the list, where the name is passed into this function (defaults to blank). - Can update an unknown set with information about attributes that do not exist in fields.