t_dbg(spec,
cond=None,
**kwd)
|
|
Decorator used to display and check properties of input and output
nodes that are passed into a node handler.
Arguments:
spec -- specifier string. A specifier string is a list of command specifiers
e.g. 'ni no co gc'. Each command spec is only two letters long.
Commands can be chained arbitrarily with or without demlimiters.
If you use delimiters use whitespace, colons, commas or semicolons.
cond -- predicate. If cond predicate is available commands will only be executed when the
input data passed the cond filter. cond has the signature cond(node, **locals).
kwd -- dictionary containing actions for commands.
Commands:
ni -- display plain node (input)
no -- display plain node(s) (output)
ci -- display input CST
co -- display output CSTs
cv -- CST validation test
so -- unparsed python source output
si -- unparsed python source input
sn -- unparsed python source of input node after
transformation. Used when input node is modified.
r1 -- check that result is a single node
r> -- check that result is a list of nodes
r= -- check that result node ids equals input node id
r! -- check that result node ids not equals input node id
fi -- arbitrary test function of one argument
executed on node input
fo -- arbitrary test function of one argument
executed on node list output
Use:
@transform_dbg("ni cv r1")
def foo(self, node):
...
@transform_dbg("r>soco")
def bar(self, node):
...
def raises(ln):
if ln>1:
raise ValueError("Only one output argument expected")
@transform_dbg("r1,co", 'r1' = raises)
def bar(self, node):
...
|