invocation-tree 0.0.17__tar.gz → 0.0.18__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {invocation_tree-0.0.17/invocation_tree.egg-info → invocation_tree-0.0.18}/PKG-INFO +1 -1
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/invocation_tree/__init__.py +33 -9
- {invocation_tree-0.0.17 → invocation_tree-0.0.18/invocation_tree.egg-info}/PKG-INFO +1 -1
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/pyproject.toml +1 -1
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/LICENSE.txt +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/MANIFEST.in +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/README.md +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/images/compute.gif +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/images/compute.py +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/images/create_gif.sh +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/images/create_images.sh +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/images/factorial.gif +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/images/factorial.py +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/images/permutations.gif +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/images/permutations.py +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/images/students.gif +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/images/students.py +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/images/vscode.png +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/invocation_tree.egg-info/SOURCES.txt +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/invocation_tree.egg-info/dependency_links.txt +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/invocation_tree.egg-info/requires.txt +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/invocation_tree.egg-info/top_level.txt +0 -0
- {invocation_tree-0.0.17 → invocation_tree-0.0.18}/setup.cfg +0 -0
|
@@ -7,7 +7,7 @@ import html
|
|
|
7
7
|
import sys
|
|
8
8
|
import difflib
|
|
9
9
|
|
|
10
|
-
__version__ = "0.0.
|
|
10
|
+
__version__ = "0.0.18"
|
|
11
11
|
__author__ = 'Bas Terwijn'
|
|
12
12
|
|
|
13
13
|
def highlight_diff(str1, str2):
|
|
@@ -107,6 +107,7 @@ class Invocation_Tree:
|
|
|
107
107
|
self.edges = []
|
|
108
108
|
self.is_highlighted = False
|
|
109
109
|
self.graph = None
|
|
110
|
+
self.prev_global_tracer = None
|
|
110
111
|
self.ignore_calls = {'Invocation_Tree.__exit__', 'Invocation_Tree.stop_trace'}
|
|
111
112
|
|
|
112
113
|
def __repr__(self):
|
|
@@ -114,13 +115,11 @@ class Invocation_Tree:
|
|
|
114
115
|
|
|
115
116
|
def __call__(self, fun, *args, **kwargs):
|
|
116
117
|
try:
|
|
117
|
-
sys.
|
|
118
|
-
|
|
118
|
+
self.prev_global_tracer = sys.gettrace()
|
|
119
|
+
sys.settrace(self.global_tracer)
|
|
119
120
|
result = fun(*args, **kwargs)
|
|
120
|
-
print('fun() ended')
|
|
121
121
|
finally:
|
|
122
|
-
sys.settrace(
|
|
123
|
-
print('fun() finally')
|
|
122
|
+
sys.settrace(self.prev_global_tracer)
|
|
124
123
|
return result
|
|
125
124
|
|
|
126
125
|
def value_to_string(self, key, value, use_repr=False):
|
|
@@ -258,8 +257,7 @@ class Invocation_Tree:
|
|
|
258
257
|
def get_graph(self):
|
|
259
258
|
return self.graph
|
|
260
259
|
|
|
261
|
-
def
|
|
262
|
-
print('trace_calls file:', frame.f_code.co_filename, 'line:', frame.f_lineno)
|
|
260
|
+
def trace(self, frame, event, arg):
|
|
263
261
|
class_fun_name = get_class_function_name(frame)
|
|
264
262
|
if not class_fun_name in self.ignore_calls:
|
|
265
263
|
if event == 'call':
|
|
@@ -274,7 +272,33 @@ class Invocation_Tree:
|
|
|
274
272
|
self.output_graph(frame, event)
|
|
275
273
|
elif event == 'line' and self.each_line:
|
|
276
274
|
self.output_graph(frame, event)
|
|
277
|
-
|
|
275
|
+
|
|
276
|
+
def global_tracer(self, frame, event, arg):
|
|
277
|
+
""" Global trace function that chains to any previous global tracer so it works in a debugger too. """
|
|
278
|
+
self.trace(frame, event, arg)
|
|
279
|
+
# call previous global tracer if any existed
|
|
280
|
+
prev_local_tracer = self.prev_global_tracer(frame, event, arg) if self.prev_global_tracer else None
|
|
281
|
+
|
|
282
|
+
def local_tracer(frame, event, arg):
|
|
283
|
+
""" Global trace is for a 'call' event that signals a new frame, it returns a local tracer to
|
|
284
|
+
handle other events in that frame. """
|
|
285
|
+
self.trace(frame, event, arg)
|
|
286
|
+
return local_tracer
|
|
287
|
+
|
|
288
|
+
def local_multiplexer(frame, event, arg):
|
|
289
|
+
""" Multiplexes between the local tracer and any previous local tracer so it works in a debugger too. """
|
|
290
|
+
# call local tracer
|
|
291
|
+
new_local_tracer = local_tracer(frame, event, arg)
|
|
292
|
+
if prev_local_tracer is not None:
|
|
293
|
+
# call previous local tracer if any existed
|
|
294
|
+
new_prev_local_tracer = prev_local_tracer(frame, event, arg)
|
|
295
|
+
# if previous local tracer returns None, stop tracing this frame as debugger probably stopped it
|
|
296
|
+
if new_prev_local_tracer is None:
|
|
297
|
+
return None
|
|
298
|
+
return new_local_tracer
|
|
299
|
+
|
|
300
|
+
return local_multiplexer
|
|
301
|
+
|
|
278
302
|
|
|
279
303
|
def blocking(filename='tree.pdf'):
|
|
280
304
|
return Invocation_Tree(filename=filename)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invocation_tree-0.0.17 → invocation_tree-0.0.18}/invocation_tree.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|