module documentation

Creates ProgramGraphs from a program or function's AST.

A ProgramGraph represents a Python program or function. The nodes in a ProgramGraph represent an Instruction (see instruction.py), an AST node, or a piece of syntax from the program. The edges in a ProgramGraph represent the relationships between these nodes.

Class ProgramGraph A ProgramGraph represents a Python program or function.
Class ProgramGraphNode A single node in a Program Graph.
Class SyntaxNodeUnparser An Unparser class helpful for creating Syntax Token nodes for fn graphs.
Function dump_node Undocumented
Function get_program_graph Constructs a program graph to represent the given program.
Function is_ast_edge Undocumented
Function is_ast_node Undocumented
Function is_syntax_edge Undocumented
Function make_list_field_name Undocumented
Function make_node_for_ast_list Undocumented
Function make_node_from_ast_node Creates a program graph node for the provided AST node.
Function make_node_from_ast_value Creates a ProgramGraphNode for the provided value.
Function make_node_from_instruction Creates a ProgramGraphNode corresponding to an existing Instruction.
Function make_node_from_syntax Undocumented
Function parse_list_field_name Undocumented
Constant INDENT_TOKEN Undocumented
Constant NEWLINE_TOKEN Undocumented
Constant UNINDENT_TOKEN Undocumented
def dump_node(node): (source)

Undocumented

def get_program_graph(program): (source)

Constructs a program graph to represent the given program.

def is_ast_edge(edge): (source)

Undocumented

def is_ast_node(node): (source)

Undocumented

def is_syntax_edge(edge): (source)

Undocumented

def make_list_field_name(field_name, index): (source)

Undocumented

def make_node_for_ast_list(): (source)

Undocumented

def make_node_from_ast_node(ast_node): (source)

Creates a program graph node for the provided AST node.

This is only called when the AST node doesn't already correspond to an Instruction in the program's control flow graph.

Parameters
ast_nodeAn AST node from the program being analyzed.
Returns
A node in the program graph corresponding to the AST node.
def make_node_from_ast_value(value): (source)

Creates a ProgramGraphNode for the provided value.

value is a primitive value appearing in a Python AST.

For example, the number 1 in Python has AST Num(n=1). In this, the value '1' is a primitive appearing in the AST. It gets its own ProgramGraphNode with node_type AST_VALUE.

Parameters
valueA primitive value appearing in an AST.
Returns
A ProgramGraphNode corresponding to the provided value.
def make_node_from_instruction(instruction): (source)

Creates a ProgramGraphNode corresponding to an existing Instruction.

Parameters
instructionAn Instruction object.
Returns
A ProgramGraphNode corresponding to that instruction.
def make_node_from_syntax(text): (source)

Undocumented

def parse_list_field_name(list_field_name): (source)

Undocumented

INDENT_TOKEN: str = (source)

Undocumented

Value
'#INDENT#'
NEWLINE_TOKEN: str = (source)

Undocumented

Value
'#NEWLINE#'
UNINDENT_TOKEN: str = (source)

Undocumented

Value
'#UNINDENT#'