ssg.boolean_expression module

Common functions for Boolean Expressions

class ssg.boolean_expression.Algebra(symbol_cls, function_cls)[source]

Bases: BooleanAlgebra

Base class for boolean algebra.

The Algebra class parses and evaluates boolean expressions, where operators can be any combination of “~, &, |, !, *, +, not, and, or” and variable symbols can contain version specifiers as described in PEP440 and PEP508. - No white space is allowed inside specifier expressions. - The ~= specifier operator is not supported.

Limitations: - no white space is allowed inside specifier expressions; - ~= specifier operator is not supported.

Example

“(oranges>=2.0.8,<=5 | fried[banana]) and !pie[apple]”

symbol_cls

The class used for symbols in the boolean expressions.

Type:

class

function_cls

The class used for functions in the boolean expressions.

Type:

class

class ssg.boolean_expression.Function(*args)[source]

Bases: Function

Base class for boolean functions.

This class should be subclassed and passed to the Algebra as function_cls to enrich expression elements with domain-specific methods.

as_id()[source]

Generate a string representation of the boolean expression.

This method constructs a unique identifier for the boolean expression by recursively calling as_id on its arguments and combining them with the appropriate boolean operator.

Returns:

A string representing the boolean expression. If the expression is a negation, it

returns ‘not_’ followed by the identifier of the negated argument. If the expression is a conjunction or disjunction, it returns the identifiers of the arguments joined by ‘_and_’ or ‘_or_’.

Return type:

str

is_and()[source]
is_not()[source]
is_or()[source]
class ssg.boolean_expression.Symbol(obj)[source]

Bases: Symbol

Symbol class represents a boolean symbol with domain-specific methods.

This class should be subclassed and passed to the Algebra as symbol_cls to enrich expression elements with domain-specific methods.

requirement

The requirement object associated with the symbol.

Type:

requirement_specs.Requirement

obj

Alias for the requirement attribute.

Type:

requirement_specs.Requirement

property arg
as_dict()[source]
as_id()[source]
static get_base_of_parametrized_name(name)[source]
has_version_specs()[source]
static is_parametrized(name)[source]
property name