selinon.predicate module

Predicate interface - predicate for building conditions.

class selinon.predicate.Predicate[source]

Bases: object

An abstract predicate representation.

ast()[source]

Python AST of this predicate (construct transitively for all indirect children as well).

Returns:AST of describing all children predicates
check()[source]

Recursively/transitively check predicate correctness.

Raises:ValueError – if predicate is not correct
static construct(tree, nodes_from, flow, can_inspect_results=True)[source]

Top-down creation of predicates - recursively called to construct predicates.

Parameters:
  • tree (dict) – a dictionary describing nodes
  • nodes_from – nodes which are used within edge
  • flow (Flow) – flow to which predicate belongs to
  • can_inspect_results (bool) – True if predicates in the condition can query task result
Return type:

Predicate

static construct_condition_name(flow_name, idx)[source]

Create condition name for a dump.

Parameters:
  • flow_name (str) – flow name
  • idx (int) – index of condition within the flow
Returns:

condition function representation

static construct_default(flow)[source]

Construct default predicate for edge.

Parameters:flow (Flow) – flow to which predicate belongs to
Return type:Predicate
static construct_default_dict()[source]

Construct default predicate definition as it would be written in the configuration file.

classmethod create(tree, nodes_from, flow, can_inspect_results)[source]

Create the predicate.

Parameters:
  • tree (List) – node from which should be predicate instantiated
  • nodes_from (List[Nodes]) – nodes which are used within edge definition
  • flow (Flow) – flow to which predicate belongs to
  • can_inspect_results (bool) – True if predicates in the condition can query task result
Returns:

Predicate instance

nodes_used()[source]

Compute all nodes that are used (transitively) by child/children.

Returns:list of nodes that are used
Return type:List[Node]
predicates_used()[source]

Compute all predicates that are used (transitively) by child/children.

Returns:used predicates by children
Return type:List[Predicate]
requires_message()[source]

Recursively check if one of the predicates require message from storage (result of previous task).

Returns:True if a result from storage is required
to_source()[source]

Construct predicate source code.

Returns:predicate source code