invocation-tree 0.0.34__tar.gz → 0.0.35__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: invocation_tree
3
- Version: 0.0.34
3
+ Version: 0.0.35
4
4
  Summary: Generates an invocation tree of functions calls.
5
5
  Author-email: Bas Terwijn <bterwijn@gmail.com>
6
6
  License-Expression: BSD-2-Clause
@@ -32,6 +32,8 @@ Run a live demo in the 👉 [**Invocation Tree Web Debugger**](https://invocatio
32
32
  - shows the invocation tree (call tree) of a program **in real time**
33
33
  - helps to **understand recursion** and its depth-first nature
34
34
 
35
+ The new `@ivt.show` [decorator interface](#decorator) now allows to scale to application in **production code**.
36
+
35
37
  # Topics #
36
38
 
37
39
  [Iteration and Recursion](#iteration-and-recursion)
@@ -546,12 +548,12 @@ ignores all function of `namespace`.
546
548
 
547
549
  ## Decorator ##
548
550
 
549
- A better way to hide functions is to use the `@ivt.show` decorator on only the functions you want to graph. The decorator uses the global `ivt.decorator_tree`.
551
+ A better way to hide functions is to use the `@ivt.show` decorator on only the functions you want to graph. The decorator uses the global `ivt.decorator_tree` tree.
550
552
 
551
553
  ```python
552
554
  import invocation_tree as ivt
553
-
554
- ivt.decorator_tree = ivt.blocking() # set tree used by decorator
555
+ ivt.decorator_tree = ivt.blocking() # set tree used by decorator
556
+ #ivt.decorator_tree = ivt.blocking_each_change() # block at each change, but much slower
555
557
 
556
558
  @ivt.show # use decorator to select which functions to graph
557
559
  def permutations(elements, perm, n):
@@ -559,9 +561,11 @@ def permutations(elements, perm, n):
559
561
  print(perm)
560
562
  else:
561
563
  for element in elements:
562
- permutations(elements, perm + '\n' + element, n-1)
563
-
564
- permutations( 'LR', '', 3) # all permutations of L and R of length 3
564
+ perm.append(element)
565
+ permutations(elements, perm, n-1)
566
+ perm.pop()
567
+
568
+ permutations( 'LR', [], 3) # all permutations of L and R of length 3
565
569
  ```
566
570
 
567
571
  ## Blocking ##
@@ -12,6 +12,8 @@ Run a live demo in the 👉 [**Invocation Tree Web Debugger**](https://invocatio
12
12
  - shows the invocation tree (call tree) of a program **in real time**
13
13
  - helps to **understand recursion** and its depth-first nature
14
14
 
15
+ The new `@ivt.show` [decorator interface](#decorator) now allows to scale to application in **production code**.
16
+
15
17
  # Topics #
16
18
 
17
19
  [Iteration and Recursion](#iteration-and-recursion)
@@ -526,12 +528,12 @@ ignores all function of `namespace`.
526
528
 
527
529
  ## Decorator ##
528
530
 
529
- A better way to hide functions is to use the `@ivt.show` decorator on only the functions you want to graph. The decorator uses the global `ivt.decorator_tree`.
531
+ A better way to hide functions is to use the `@ivt.show` decorator on only the functions you want to graph. The decorator uses the global `ivt.decorator_tree` tree.
530
532
 
531
533
  ```python
532
534
  import invocation_tree as ivt
533
-
534
- ivt.decorator_tree = ivt.blocking() # set tree used by decorator
535
+ ivt.decorator_tree = ivt.blocking() # set tree used by decorator
536
+ #ivt.decorator_tree = ivt.blocking_each_change() # block at each change, but much slower
535
537
 
536
538
  @ivt.show # use decorator to select which functions to graph
537
539
  def permutations(elements, perm, n):
@@ -539,9 +541,11 @@ def permutations(elements, perm, n):
539
541
  print(perm)
540
542
  else:
541
543
  for element in elements:
542
- permutations(elements, perm + '\n' + element, n-1)
543
-
544
- permutations( 'LR', '', 3) # all permutations of L and R of length 3
544
+ perm.append(element)
545
+ permutations(elements, perm, n-1)
546
+ perm.pop()
547
+
548
+ permutations( 'LR', [], 3) # all permutations of L and R of length 3
545
549
  ```
546
550
 
547
551
  ## Blocking ##
@@ -10,7 +10,7 @@ import functools
10
10
 
11
11
  import invocation_tree.regex_set as regset
12
12
 
13
- __version__ = "0.0.34"
13
+ __version__ = "0.0.35"
14
14
  __author__ = 'Bas Terwijn'
15
15
 
16
16
  def highlight_diff(str1, str2):
@@ -150,7 +150,8 @@ class Invocation_Tree:
150
150
  if len(val_str) > self.max_string_len:
151
151
  val_str = '...'+val_str[-self.max_string_len:]
152
152
  result = html.escape(val_str)
153
- result = result.replace('\n', '<BR/>') # use HTML line breaks
153
+ if '\n' in result:
154
+ result = '<BR/>' + result.replace('\n', '<BR/>') # use HTML line breaks
154
155
  return result
155
156
 
156
157
  def get_hightlighted_content(self, tree_node, key, value, use_old_content=False):
@@ -399,6 +400,14 @@ def show(fun):
399
400
 
400
401
  def tracer(frame, event, arg):
401
402
  nonlocal active_depth
403
+
404
+ if event == "exception":
405
+ exc_type, exc, tb = arg
406
+ if exc_type is KeyboardInterrupt:
407
+ # ensure we stop tracing before bailing out
408
+ sys.settrace(prev_tracer)
409
+ raise exc.with_traceback(tb)
410
+
402
411
  # Check if this is our target function
403
412
  if frame.f_code is target_code:
404
413
  if event == "call":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: invocation_tree
3
- Version: 0.0.34
3
+ Version: 0.0.35
4
4
  Summary: Generates an invocation tree of functions calls.
5
5
  Author-email: Bas Terwijn <bterwijn@gmail.com>
6
6
  License-Expression: BSD-2-Clause
@@ -32,6 +32,8 @@ Run a live demo in the 👉 [**Invocation Tree Web Debugger**](https://invocatio
32
32
  - shows the invocation tree (call tree) of a program **in real time**
33
33
  - helps to **understand recursion** and its depth-first nature
34
34
 
35
+ The new `@ivt.show` [decorator interface](#decorator) now allows to scale to application in **production code**.
36
+
35
37
  # Topics #
36
38
 
37
39
  [Iteration and Recursion](#iteration-and-recursion)
@@ -546,12 +548,12 @@ ignores all function of `namespace`.
546
548
 
547
549
  ## Decorator ##
548
550
 
549
- A better way to hide functions is to use the `@ivt.show` decorator on only the functions you want to graph. The decorator uses the global `ivt.decorator_tree`.
551
+ A better way to hide functions is to use the `@ivt.show` decorator on only the functions you want to graph. The decorator uses the global `ivt.decorator_tree` tree.
550
552
 
551
553
  ```python
552
554
  import invocation_tree as ivt
553
-
554
- ivt.decorator_tree = ivt.blocking() # set tree used by decorator
555
+ ivt.decorator_tree = ivt.blocking() # set tree used by decorator
556
+ #ivt.decorator_tree = ivt.blocking_each_change() # block at each change, but much slower
555
557
 
556
558
  @ivt.show # use decorator to select which functions to graph
557
559
  def permutations(elements, perm, n):
@@ -559,9 +561,11 @@ def permutations(elements, perm, n):
559
561
  print(perm)
560
562
  else:
561
563
  for element in elements:
562
- permutations(elements, perm + '\n' + element, n-1)
563
-
564
- permutations( 'LR', '', 3) # all permutations of L and R of length 3
564
+ perm.append(element)
565
+ permutations(elements, perm, n-1)
566
+ perm.pop()
567
+
568
+ permutations( 'LR', [], 3) # all permutations of L and R of length 3
565
569
  ```
566
570
 
567
571
  ## Blocking ##
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "invocation_tree"
7
- version = "0.0.34"
7
+ version = "0.0.35"
8
8
  description = "Generates an invocation tree of functions calls."
9
9
  authors = [
10
10
  {name = "Bas Terwijn", email = "bterwijn@gmail.com"}