-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebugger.py
36 lines (30 loc) · 1.02 KB
/
debugger.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
# debugger.py
# This file autogenerated from gps_py.org
# Identifiers used by dbg.
_dbg_ids_ = []
def dbg (target, format_string, *args):
"""Print debugging information if target has been specified"""
if target in _dbg_ids_:
print(format_string.format(args))
def debug(*ids):
"""Start dbg output the given ids."""
global _dbg_ids_
_dbg_ids_ = _dbg_ids_ + list(ids)
def list_diff(minuend, subtrahend):
"""Remove the elements of the subtrahend from the minuend."""
return [val for val in minuend if val not in subtrahend]
def undebug(*ids):
"""Stop dbg on the ids. If no ids, stop all debugging"""
global _dbg_ids_
if ids:
_dbg_ids_ = list_diff(_dbg_ids_, list(ids))
else:
_dbg_ids_ = []
def dbg_indent (target, indent, format_string, *args):
"""Print indented debugging info if target has been specified"""
if target in _dbg_ids_:
s = ""
for i in range(indent):
s += " "
s = s + format_string
print(s.format(args))