-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassifier.py
More file actions
28 lines (25 loc) · 1.04 KB
/
Copy pathclassifier.py
File metadata and controls
28 lines (25 loc) · 1.04 KB
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
import json
#import inspect
#from executing import Source
# NB: borrowed this code from substack. Requires executing and asttokens.
# if included inline in varDump, would allow retrieval of variable name
# and its value. So could be used to get varname...
#def get_var_name(var):
# callFrame = inspect.currentframe().f_back
# callNode = Source.executing(callFrame).node
# source = Source.for_frame(callFrame)
# expression = source.asttokens().get_text(callNode.args[0])
# print(expression, '=', var)
def varDump(some_value, description='', dump_type='print'):
# in honor of PHP lmao
sv_type = type(some_value)
print('')
print(f'{description}\t\ttype:\t{sv_type}')
if dump_type == 'json':
print(f'{json.dumps(some_value,indent=4)}')
else:
# so pretty much dump_type other than json prints the value straight up
print(f"{some_value}")
def pretty_print_sql(sql_statement, method=''):
pretty_sql = ' '.join(sql_statement.split())
print(f"{method} SQL statement is: {pretty_sql}")