class ast_traverse_directives¶
Flag class: specifies behavior during traversal with an ast_iterator .
Apply with ast_iterator.apply_directives() at any point during traversal.
- Only meaningful for preorder traversals (that is, those where
ast_traverse_flags.POSTORDERis NOT specified). - Otherwise, traversal continues as previously specified.
ast_traverse_directives Members¶
| Constructors | none |
| Static Method | from_integer() |
| Methods | __and__(), __cmp__(), __eq__(), __ge__(), __gt__(), __hash__(), __invert__(), __le__(), __lt__(), __ne__(), __or__(), __repr__(), __str__(), as_integer(), name() |
| Attributes | NONE, SKIP_CHILDREN |
ast_traverse_directives Details¶
-
class
cs.ast_traverse_directives¶ Flag class: specifies behavior during traversal with an
ast_iterator.-
static
from_integer(_inner)¶ Construct an instance from an integer representation.
Parameters: _inner (int) – The integer representation, as returned by ast_traverse_directives.as_integer().Return type: ast_traverse_directivesRaises: result.ERROR_INVALID_ARGUMENTif_inneris not a valid integer representation for aast_traverse_directivesinstance.Invariant: For
ast_traverse_directivesx, ast_traverse_directives.from_integer(x.as_integer()) == x>>> atd = ast_traverse_directives.SKIP_CHILDREN.as_integer() >>> atd 1 >>> ast_traverse_directives.from_integer(atd) <cs.ast_traverse_directives skip_children>
-
__and__(b)¶ AND operator for
ast_traverse_directives.Parameters: b ( ast_traverse_directives) – AND operand.Return type: ast_traverse_directivesReturns: A ast_traverse_directivesobject containing all flags that are in bothselfandb.>>> ast_traverse_directives.SKIP_CHILDREN & ast_traverse_directives.NONE <cs.ast_traverse_directives none>
-
__cmp__(other)¶ Comparison function for
ast_traverse_directives, with respect to a stable overall ordering.Parameters: other ( ast_traverse_directives) – Theast_traverse_directivesobject 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
>>> ast_traverse_directives.SKIP_CHILDREN.__cmp__(ast_traverse_directives.SKIP_CHILDREN) 0
-
__eq__(b)¶ Equality operator for
ast_traverse_directives.Parameters: b ( ast_traverse_directives) – Theast_traverse_directivesobject to compare against.Return type: bool Returns: Trueifselfandbcompare equal,Falseotherwise.>>> ast_traverse_directives.NONE == ast_traverse_directives.SKIP_CHILDREN False
-
__ge__(b)¶ Greater-than-or-equal operator for
ast_traverse_directives.Parameters: b ( ast_traverse_directives) – Theast_traverse_directivesobject to compare against.Return type: bool Returns: Trueifself>=b,Falseotherwise.>>> ast_traverse_directives.NONE >= ast_traverse_directives.SKIP_CHILDREN False
-
__gt__(b)¶ Greater-than operator for
ast_traverse_directives.Parameters: b ( ast_traverse_directives) – Theast_traverse_directivesobject to compare against.Return type: bool Returns: Trueifself>b,Falseotherwise.>>> ast_traverse_directives.NONE > ast_traverse_directives.SKIP_CHILDREN False
-
__hash__()¶ Hash function for
ast_traverse_directives.Return type: int >>> hash(ast_traverse_directives.NONE) 0
-
__invert__()¶ Complementation operator.
Return type: ast_traverse_directivesReturns: A ast_traverse_directivesobject containing the flags that are NOT contained inself.>>> ~ast_traverse_directives.SKIP_CHILDREN <cs.ast_traverse_directives none>
-
__le__(b)¶ Less-than-or-equal operator for
ast_traverse_directives.Parameters: b ( ast_traverse_directives) – Theast_traverse_directivesobject to compare against.Return type: bool Returns: Trueifself<=b,Falseotherwise.>>> ast_traverse_directives.NONE <= ast_traverse_directives.SKIP_CHILDREN True
-
__lt__(b)¶ Less-than operator for
ast_traverse_directives.Parameters: b ( ast_traverse_directives) – Theast_traverse_directivesobject to compare against.Return type: bool Returns: Trueifself<b,Falseotherwise.>>> ast_traverse_directives.SKIP_CHILDREN < ast_traverse_directives.NONE False
-
__ne__(b)¶ Inequality operator for
ast_traverse_directives.Parameters: b ( ast_traverse_directives) – Theast_traverse_directivesobject to compare against.Return type: bool Returns: Falseifselfandbcompare equal,Trueotherwise.>>> ast_traverse_directives.SKIP_CHILDREN != ast_traverse_directives.NONE True
-
__or__(b)¶ OR operator for
ast_traverse_directives.Parameters: b ( ast_traverse_directives) – OR operand.Return type: ast_traverse_directivesReturns: A ast_traverse_directivesobject containing all flags that are in at least one ofself,b.>>> ast_traverse_directives.SKIP_CHILDREN | ast_traverse_directives.NONE <cs.ast_traverse_directives skip_children>
-
__repr__()¶ Get a representation of a
ast_traverse_directivesobject that includes information useful for debugging.Return type: str Returns: The string representation. >>> repr(ast_traverse_directives.NONE) '<cs.ast_traverse_directives none>'
-
__str__()¶ Get a simple string representation of a
ast_traverse_directivesobject.Return type: str Returns: The string representation. >>> str(ast_traverse_directives.SKIP_CHILDREN) 'skip_children'
-
as_integer()¶ Get an integer representation of
self.Return type: int Returns: An integer suitable for use with ast_traverse_directives.from_integer().Invariant: For
ast_traverse_directivesx, ast_traverse_directives.from_integer(x.as_integer()) == x>>> atd = ast_traverse_directives.SKIP_CHILDREN.as_integer() >>> atd 1 >>> ast_traverse_directives.from_integer(atd) <cs.ast_traverse_directives skip_children>
-
name()¶ Get the name of a
ast_traverse_directivesobject.Return type: str >>> ast_traverse_directives.NONE.name() 'none'
-
NONE¶ No directives set.
>>> ast_traverse_directives.NONE <cs.ast_traverse_directives none>
-
SKIP_CHILDREN¶ Skip the children of the current node, but continue with remainder of traversal.
>>> ast_traverse_directives.SKIP_CHILDREN <cs.ast_traverse_directives skip_children>
-
static