-
Notifications
You must be signed in to change notification settings - Fork 1
/
qa_debug.py
65 lines (54 loc) · 1.59 KB
/
qa_debug.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 21 13:36:29 2018
@author: gehammo
"""
verbose = True
verbose = False
verbosity_ceiling = 5
verbose_error = False
indent_increment = 0
#indent_increment = 2
append_increment_integer = False
#append_increment_integer = True
if indent_increment == 0:
append_increment_integer = False
stack = []
def debug_push(string):
stack.append(string)
if verbose and len(stack) <= verbosity_ceiling:
m = len(stack)
indent_string = ' '*(m*indent_increment)
stack_string = debug_top_of_stack()
if append_increment_integer:
print('Begin '+indent_string+stack_string+' {}'.format(m))
else:
print('Begin '+indent_string+stack_string)
def debug_pop():
if verbose and len(stack) <= verbosity_ceiling:
m = len(stack)
indent_string = ' '*(m*indent_increment)
stack_string = debug_top_of_stack()
if append_increment_integer:
print('End '+indent_string+stack_string+' {}'.format(m))
else:
print('End '+indent_string+stack_string)
stack.pop()
def debug_top_of_stack():
if len(stack) > 0:
return stack[len(stack)-1]
return None
def debug_verbose():
if verbose:
return True
return False
def debug_verbose_error():
if verbose_error:
return True
return False
def debug_finalize():
if not len(stack) == 0:
print('\nERROR: Debug stack is not zero: {}\n'.format(len(stack)))
while len(stack) > 0:
print(' {}'.format(debug_top_of_stack()))
stack.pop()