invocation-tree 0.0.36__tar.gz → 0.0.37__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.36 → invocation_tree-0.0.37}/PKG-INFO +1 -1
- {invocation_tree-0.0.36 → invocation_tree-0.0.37}/invocation_tree/__init__.py +53 -15
- {invocation_tree-0.0.36 → invocation_tree-0.0.37}/invocation_tree.egg-info/PKG-INFO +1 -1
- {invocation_tree-0.0.36 → invocation_tree-0.0.37}/pyproject.toml +1 -1
- {invocation_tree-0.0.36 → invocation_tree-0.0.37}/LICENSE.txt +0 -0
- {invocation_tree-0.0.36 → invocation_tree-0.0.37}/README.md +0 -0
- {invocation_tree-0.0.36 → invocation_tree-0.0.37}/invocation_tree/regex_set.py +0 -0
- {invocation_tree-0.0.36 → invocation_tree-0.0.37}/invocation_tree.egg-info/SOURCES.txt +0 -0
- {invocation_tree-0.0.36 → invocation_tree-0.0.37}/invocation_tree.egg-info/dependency_links.txt +0 -0
- {invocation_tree-0.0.36 → invocation_tree-0.0.37}/invocation_tree.egg-info/requires.txt +0 -0
- {invocation_tree-0.0.36 → invocation_tree-0.0.37}/invocation_tree.egg-info/top_level.txt +0 -0
- {invocation_tree-0.0.36 → invocation_tree-0.0.37}/setup.cfg +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Copyright (c) 2023, Bas Terwijn.
|
|
3
3
|
# SPDX-License-Identifier: BSD-2-Clause
|
|
4
4
|
|
|
5
|
-
from graphviz import Digraph
|
|
5
|
+
from graphviz import Digraph, Source
|
|
6
6
|
import html
|
|
7
7
|
import sys
|
|
8
8
|
import difflib
|
|
@@ -10,7 +10,7 @@ import functools
|
|
|
10
10
|
|
|
11
11
|
import invocation_tree.regex_set as regset
|
|
12
12
|
|
|
13
|
-
__version__ = "0.0.
|
|
13
|
+
__version__ = "0.0.37"
|
|
14
14
|
__author__ = 'Bas Terwijn'
|
|
15
15
|
|
|
16
16
|
# colors dark
|
|
@@ -27,6 +27,13 @@ color_paused_dark = '#779977'
|
|
|
27
27
|
color_active_dark = '#1d1d1d'
|
|
28
28
|
color_returned_dark = '#997777'
|
|
29
29
|
|
|
30
|
+
# color placeholders
|
|
31
|
+
foreground_color_PH = 'foreground_color_PH'
|
|
32
|
+
background_color_PH = 'background_color_PH'
|
|
33
|
+
color_paused_PH = 'color_paused_PH'
|
|
34
|
+
color_active_PH = 'color_active_PH'
|
|
35
|
+
color_returned_PH = 'color_returned_PH'
|
|
36
|
+
|
|
30
37
|
|
|
31
38
|
def highlight_diff(str1, str2):
|
|
32
39
|
matcher = difflib.SequenceMatcher(None, str1, str2)
|
|
@@ -133,6 +140,7 @@ class Invocation_Tree:
|
|
|
133
140
|
self.is_highlighted = False
|
|
134
141
|
self.graph = None
|
|
135
142
|
self.prev_global_tracer = None
|
|
143
|
+
self.uncolored_graph = None
|
|
136
144
|
|
|
137
145
|
def __repr__(self):
|
|
138
146
|
return f'Invocation_Tree(filename={repr(self.filename)}, show={self.show}, block={self.block}, each_line={self.each_line}, gifcount={self.gifcount})'
|
|
@@ -230,8 +238,8 @@ class Invocation_Tree:
|
|
|
230
238
|
border = 3
|
|
231
239
|
if is_returned:
|
|
232
240
|
color = self.color_returned
|
|
233
|
-
alignment = 'ALIGN="
|
|
234
|
-
table = f'<\n<TABLE BORDER="{str(border)}" COLOR="{
|
|
241
|
+
alignment = 'ALIGN="LEFT" BALIGN="LEFT"'
|
|
242
|
+
table = f'<\n<TABLE BORDER="{str(border)}" COLOR="{foreground_color_PH}" CELLBORDER="0" CELLSPACING="0" BGCOLOR="{color}">\n <TR>'
|
|
235
243
|
class_fun_name = get_class_function_name(tree_node.frame)
|
|
236
244
|
local_vars = tree_node.frame.f_locals
|
|
237
245
|
hightlighted_content = self.get_hightlighted_content(tree_node, class_fun_name, class_fun_name, use_old_content)
|
|
@@ -270,29 +278,62 @@ class Invocation_Tree:
|
|
|
270
278
|
return '.'.join(splits)
|
|
271
279
|
return self.filename
|
|
272
280
|
|
|
273
|
-
def
|
|
281
|
+
def graph_header(self):
|
|
274
282
|
graphviz_graph_attr = {
|
|
275
283
|
'fontname': self.fontname,
|
|
276
284
|
'fontsize': str(self.fontsize),
|
|
277
|
-
'fontcolor':
|
|
278
|
-
'bgcolor':
|
|
285
|
+
'fontcolor': foreground_color_PH,
|
|
286
|
+
'bgcolor': background_color_PH,
|
|
279
287
|
}
|
|
280
288
|
graphviz_node_attr = {
|
|
281
289
|
'fontname': self.fontname,
|
|
282
290
|
'fontsize': str(self.fontsize),
|
|
283
291
|
'shape':'plaintext',
|
|
284
|
-
'fontcolor':
|
|
292
|
+
'fontcolor': foreground_color_PH
|
|
285
293
|
}
|
|
286
294
|
graphviz_edge_attr = {
|
|
287
295
|
'fontname': self.fontname,
|
|
288
296
|
'fontsize': str(self.fontsize),
|
|
289
|
-
'fontcolor':
|
|
290
|
-
'color':
|
|
297
|
+
'fontcolor': foreground_color_PH,
|
|
298
|
+
'color': foreground_color_PH
|
|
291
299
|
}
|
|
292
300
|
graph = Digraph('invocation_tree',
|
|
293
301
|
graph_attr=graphviz_graph_attr,
|
|
294
302
|
node_attr=graphviz_node_attr,
|
|
295
303
|
edge_attr=graphviz_edge_attr)
|
|
304
|
+
return graph
|
|
305
|
+
|
|
306
|
+
def build_graph_from_nodes(self):
|
|
307
|
+
# add nodes and edges to graph
|
|
308
|
+
graph = self.graph_header()
|
|
309
|
+
for nid, table in self.node_id_to_table.items():
|
|
310
|
+
graph.node(nid, label=table)
|
|
311
|
+
for nid1, nid2 in self.edges:
|
|
312
|
+
graph.edge(nid1, nid2)
|
|
313
|
+
return graph
|
|
314
|
+
|
|
315
|
+
def recolor_last_graph(self):
|
|
316
|
+
if not self.uncolored_graph:
|
|
317
|
+
return self.uncolored_graph
|
|
318
|
+
graph_str = self.uncolored_graph.source
|
|
319
|
+
|
|
320
|
+
def replace_color(token, value):
|
|
321
|
+
# DOT attrs like fontcolor=... need quoted #RRGGBB values.
|
|
322
|
+
result = graph_str.replace(f'={token}', f'="{value}"')
|
|
323
|
+
# HTML-like labels contain quoted placeholder values already.
|
|
324
|
+
return result.replace(token, value)
|
|
325
|
+
|
|
326
|
+
graph_str = replace_color(foreground_color_PH, self.foreground_color)
|
|
327
|
+
graph_str = replace_color(background_color_PH, self.background_color)
|
|
328
|
+
graph_str = replace_color(color_paused_PH, self.color_paused)
|
|
329
|
+
graph_str = replace_color(color_active_PH, self.color_active)
|
|
330
|
+
graph_str = replace_color(color_returned_PH, self.color_returned)
|
|
331
|
+
graph = Source(graph_str)
|
|
332
|
+
graph.engine = self.uncolored_graph.engine
|
|
333
|
+
graph.format = self.uncolored_graph.format
|
|
334
|
+
return graph
|
|
335
|
+
|
|
336
|
+
def create_graph(self):
|
|
296
337
|
# update returned nodes
|
|
297
338
|
for node in self.prev_returned:
|
|
298
339
|
self.update_node(node, use_old_content=True)
|
|
@@ -312,11 +353,8 @@ class Invocation_Tree:
|
|
|
312
353
|
self.update_node(node, active=False, use_old_content=True)
|
|
313
354
|
self.prev_paused = self.paused.copy()
|
|
314
355
|
self.paused = []
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
graph.node(nid, label=table)
|
|
318
|
-
for nid1, nid2 in self.edges:
|
|
319
|
-
graph.edge(nid1, nid2)
|
|
356
|
+
self.uncolored_graph = self.build_graph_from_nodes()
|
|
357
|
+
graph = self.recolor_last_graph()
|
|
320
358
|
return graph
|
|
321
359
|
|
|
322
360
|
def render_graph(self, graph):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{invocation_tree-0.0.36 → invocation_tree-0.0.37}/invocation_tree.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|