hunter¶
Functions
hunter.trace |
Starts tracing. |
hunter.stop |
Stop tracing. |
hunter.Q |
Handles situations where hunter.Query objects (or other callables) are passed in as positional arguments. |
Predicates
hunter.Query |
A query class. |
hunter.When |
Runs actions when condition(event) is True . |
hunter.And |
And predicate. Exits at the first sub-predicate that returns False . |
hunter.Or |
Or predicate. Exits at first sub-predicate that returns True . |
Actions
hunter.CodePrinter |
An action that just prints the code being executed. |
hunter.Debugger |
An action that starts pdb . |
hunter.VarsPrinter |
An action that prints local variables and optionally global variables visible from the current executing frame. |
Objects
hunter.Event |
Event wrapper for frame, kind, arg (the arguments the settrace function gets). |
-
hunter.
trace
(*predicates, **options)¶ Starts tracing. Can be used as a context manager (with slightly incorrect semantics - it starts tracing before
__enter__
is called).Parameters:
-
hunter.
stop
()¶ Stop tracing. Restores previous tracer (if any).
-
class
hunter.
Q
[source]¶ Handles situations where
hunter.Query
objects (or other callables) are passed in as positional arguments. Conveniently converts that to anhunter.Or
predicate.
-
class
hunter.
Query
(**query)[source]¶ A query class.
See
hunter.Event
for fields that can be filtered on.
-
class
hunter.
When
(condition, *actions)[source]¶ Runs
actions
whencondition(event)
isTrue
.Actions take a single
event
argument.
-
class
hunter.
And
(*predicates)[source]¶ And predicate. Exits at the first sub-predicate that returns
False
.
-
class
hunter.
CodePrinter
(stream=<open file '<stderr>', mode 'w'>, force_colors=False, filename_alignment=40)[source]¶ An action that just prints the code being executed.
Parameters: - stream (file-like) – Stream to write to. Default:
sys.stderr
. - filename_alignment (int) – Default size for the filename column (files are right-aligned). Default:
40
.
- stream (file-like) – Stream to write to. Default:
-
class
hunter.
VarsPrinter
(*names, **options)[source]¶ An action that prints local variables and optionally global variables visible from the current executing frame.
Parameters: - *names (strings) – Names to evaluate. Expressions can be used (will only try to evaluate if all the variables are present on the frame.
- stream (file-like) – Stream to write to. Default:
sys.stderr
. - filename_alignment (int) – Default size for the filaneme column (files are right-aligned). Default:
40
. - globals (bool) – Allow access to globals. Default:
False
(only looks at locals).
-
class
hunter.
Event
(frame, kind, arg, tracer)[source]¶ Event wrapper for
frame, kind, arg
(the arguments the settrace function gets).Provides few convenience properties.
-
fullsource
[source]¶ A string with the sourcecode for the current statement (from
linecache
- failures are ignored).May include multiple lines if it’s a class/function definition (will include decorators).
-