class xform_query_result

Enumeration class: the possible outcomes of a transform query with step_xform.query().

This class is used when implementing step visitors. When you implement step_state.transition() as part of the overall task of subclassing step_state , you will use step_xform.query() invocations to inspect its step_xform arguments; these query invocations return xform_query_result .

xform_query_result Details

class cs.xform_query_result

Enumeration class: the possible outcomes of a transform query with step_xform.query().

static from_integer(_inner)

Construct an instance from an integer representation.

Parameters:_inner (int) – The integer representation, as returned by xform_query_result.as_integer().
Return type:xform_query_result
Raises:result.ERROR_INVALID_ARGUMENT if _inner is not a valid integer representation for a xform_query_result instance.

Invariant: For xform_query_result x, xform_query_result.from_integer(x.as_integer()) == x

>>> xqr = xform_query_result.IMPOSSIBLE.as_integer()
>>> xqr
0
>>> xform_query_result.from_integer(xqr)
<cs.xform_query_result impossible>
__cmp__(other)

Comparison function for xform_query_result , with respect to a stable overall ordering.

Parameters:other (xform_query_result) – The xform_query_result object to compare against.
Return type:int
Returns:An integer N such that:
  • N==0 if the two objects compare equal
  • N<0 if self < other
  • N>0 if self > other
>>> xform_query_result.OK.__cmp__(xform_query_result.LHS_UNMODIFIED)
-1
__eq__(b)

Equality operator for xform_query_result .

Parameters:b (xform_query_result) – The xform_query_result object to compare against.
Return type:bool
Returns:True if self and b compare equal, False otherwise.
>>> xform_query_result.REDUNDANT_SUSPECT == xform_query_result.REDUNDANT
False
__ge__(b)

Greater-than-or-equal operator for xform_query_result .

Parameters:b (xform_query_result) – The xform_query_result object to compare against.
Return type:bool
Returns:True if self >= b , False otherwise.
>>> xform_query_result.IMPOSSIBLE >= xform_query_result.RHS_UNMODIFIED
False
__gt__(b)

Greater-than operator for xform_query_result .

Parameters:b (xform_query_result) – The xform_query_result object to compare against.
Return type:bool
Returns:True if self > b , False otherwise.
>>> xform_query_result.REDUNDANT_SUSPECT > xform_query_result.LHS_UNMODIFIED
False
__hash__()

Hash function for xform_query_result .

Return type:int
>>> hash(xform_query_result.IMPOSSIBLE)
0
__le__(b)

Less-than-or-equal operator for xform_query_result .

Parameters:b (xform_query_result) – The xform_query_result object to compare against.
Return type:bool
Returns:True if self <= b , False otherwise.
>>> xform_query_result.OK <= xform_query_result.REDUNDANT
False
__lt__(b)

Less-than operator for xform_query_result .

Parameters:b (xform_query_result) – The xform_query_result object to compare against.
Return type:bool
Returns:True if self < b , False otherwise.
>>> xform_query_result.REDUNDANT_SUSPECT < xform_query_result.RHS_UNMODIFIED
True
__ne__(b)

Inequality operator for xform_query_result .

Parameters:b (xform_query_result) – The xform_query_result object to compare against.
Return type:bool
Returns:False if self and b compare equal, True otherwise.
>>> xform_query_result.REDUNDANT != xform_query_result.LHS_UNMODIFIED
True
__repr__()

Get a representation of a xform_query_result object that includes information useful for debugging.

Return type:str
Returns:The string representation.
>>> repr(xform_query_result.IMPOSSIBLE)
'<cs.xform_query_result impossible>'
__str__()

Get a simple string representation of a xform_query_result object.

Return type:str
Returns:The string representation.
>>> str(xform_query_result.OK)
'ok'
as_integer()

Get an integer representation of self.

Return type:int
Returns:An integer suitable for use with xform_query_result.from_integer().

Invariant: For xform_query_result x, xform_query_result.from_integer(x.as_integer()) == x

>>> xqr = xform_query_result.IMPOSSIBLE.as_integer()
>>> xqr
0
>>> xform_query_result.from_integer(xqr)
<cs.xform_query_result impossible>
name()

Get the name of a xform_query_result object.

Return type:str
Returns:The name.
>>> xform_query_result.REDUNDANT_SUSPECT.name()
'redundant_suspect'
IMPOSSIBLE

The query evaluates to FALSE.

There are two possible cases:

  • Case 1: the query evaluates to FALSE because of preconditions that arise from:
  • Case 2: the query evaluates to FALSE for any other reason.

We use the term “suspect” to describe case 1.

If some query Q has outcome xform_query_result.IMPOSSIBLE and you need to distinguish between the two cases, proceed as follows.

  1. Create a new query R that is the inverse of Q.
  2. Execute query R and look at the outcome.
>>> xform_query_result.IMPOSSIBLE
<cs.xform_query_result impossible>
LHS_UNMODIFIED

The query’s lhs xform_expr had mode xform_expr_mode.POST_STRICT or xform_expr_mode.POST_DEREFS_PRE_STRICT, but the value of lhs was the same at the beginning and end of the transformation described by the step_xform .

>>> xform_query_result.LHS_UNMODIFIED
<cs.xform_query_result lhs_unmodified>
OK

The query could evaluate to either TRUE or FALSE: there is no reason to believe definitely one or the other.

>>> xform_query_result.OK
<cs.xform_query_result ok>
REDUNDANT

The query definitely evaluates to TRUE.

>>> xform_query_result.REDUNDANT
<cs.xform_query_result redundant>
REDUNDANT_SUSPECT

The query evaluates to TRUE, but is implied by preconditions that arise from:

>>> xform_query_result.REDUNDANT_SUSPECT
<cs.xform_query_result redundant_suspect>
RHS_UNMODIFIED

The query’s rhs xform_expr had mode xform_expr_mode.POST_STRICT or xform_expr_mode.POST_DEREFS_PRE_STRICT, but the value of rhs was the same at the beginning and end of the transformation described by the step_xform .

>>> xform_query_result.RHS_UNMODIFIED
<cs.xform_query_result rhs_unmodified>