CodeQL library for Python
codeql/python-all 0.11.13 (changelog, source)
Search

Module PrintAst

Provides queries to pretty-print a Python AST as a graph.

By default, this will print the AST for all elements in the database. To change this behavior, extend PrintAstConfiguration and override shouldPrint to hold for only the elements you wish to view the AST for.

Import path

import semmle.python.PrintAst

Imports

RegexTreeView

Provides a class hierarchy corresponding to a parse tree of regular expressions.

Yaml

Provides classes for working with YAML data.

python

Predicates

edges

Holds if target is a child of source in the AST, and property key of the edge has the given value.

graphProperties

Holds if property key of the graph has the given value.

nodes

Holds if node belongs to the output tree, and its property key has the given value.

Classes

AstElementNode

An AstNode printed in the print-viewer.

CallArgumentsNode

A synthetic print node for the arguments to call.

CallPrintNode

A print node for a Call.

ClassNode

A print node for classes.

ExceptNode

A print node for ExceptStmt.

ForPrintNode

A print node for For statements.

FunctionDefNode

A print node for a FunctionDef.

FunctionNode

A print node for a Function.

FunctionParamsNode

A print node for the parameters in func.

IfNode

A print node for If statements.

ParameterNode

A print node for a Parameter.

PrintAstConfiguration

The query can extend this class to control which elements are printed.

PrintAstNode

A node in the output tree.

StmtListNode

A print node for StmtList. A StmtListNode is always a child of an AstElementNode, and the child-parent relation is defined by the getStmtList predicate in AstElementNode.

StrConstNode

A print node for a StrConst.

TopLevelPrintAstNode

A top-level AST node.

TryNode

A print node for Try statements.

WhilePrintNode

A print node for While statements.

WithNode

A print node for With statements.

Modules

PrintYaml

Classes for printing YAML AST.