pathex.managing.trace_checker module
- class TraceChecker(expression: Expression, machine: DecomposerMatch | None = None)[source]
Bases:
pathex.managing.manager.Manager
This class is just to demonstrate the use of manager for other tasks different than task synchronization.
>>> from pathex import Tag >>> a, b, c = Tag.named('func_a', 'func_b', 'func_c') >>> trace_checker = TraceChecker((a+b+c)*...)
>>> @trace_checker.region(a) ... def func_a(): ... return 'func_a'
>>> @trace_checker.region(b) ... def func_b(): ... return 'func_b'
>>> @trace_checker.region(c) ... def func_c(): ... return 'func_c'
>>> func_b(), func_a(), func_c() Traceback (most recent call last): ... AssertionError: func_b.enter is not allowed as first label
>>> func_a(), func_b(), func_c() ('func_a', 'func_b', 'func_c')
>>> func_a(), func_c(), func_b() Traceback (most recent call last): ... AssertionError: func_c.enter is not allowed after func_a.exit
>>> func_b(), func_c() ('func_b', 'func_c')
- match(label: object) object [source]
This method is used to notify to the manager the presence of a given label.
The manager then see if this label is allowed by checking if the internal expression can generate the given label. If the label is allowed or not, a respective action is taken.
- Parameters
label (Hashable) – The label to check for.