graphtage.constraints

constraints classes

ConditionalMatcher

class graphtage.constraints.ConditionalMatcher(condition: Expression)

Bases: object

Decides whether two nodes may be paired, based on a commandline expression.

The expression is evaluated with from and to bound to the TreeNode.to_obj() representations of the two nodes, so it operates on plain Python values rather than on Graphtage’s node objects.

Constraints are attached to every node of a tree, so an expression written for one kind of node will raise on the others; for example, subscripting a string by a dictionary key raises a TypeError. An expression that raises leaves the pair unconstrained rather than refusing it.

__init__(condition: Expression)
classmethod apply(node: TreeNode, condition: Expression)

MatchIf

class graphtage.constraints.MatchIf(condition: Expression)

Bases: ConditionalMatcher

Refuses to pair two nodes unless the condition evaluates to a true value.

__init__(condition: Expression)
classmethod apply(node: TreeNode, condition: Expression)

MatchUnless

class graphtage.constraints.MatchUnless(condition: Expression)

Bases: ConditionalMatcher

Refuses to pair two nodes when the condition evaluates to a true value.

__init__(condition: Expression)
classmethod apply(node: TreeNode, condition: Expression)