forked from visualpython/visualpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprintCommand.py
More file actions
23 lines (21 loc) · 741 Bytes
/
printCommand.py
File metadata and controls
23 lines (21 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Libraries
import numpy as _vp_np
import json as _vp_json
import warnings as _vp_warnings
class _VpNpEncoder(_vp_json.JSONEncoder):
def default(self, obj):
if isinstance(obj, _vp_np.integer):
return int(obj)
if isinstance(obj, _vp_np.floating):
return float(obj)
if isinstance(obj, _vp_np.ndarray):
return obj.tolist()
return super(_VpNpEncoder, self).default(obj)
def _vp_print(command):
"""
Print with json.dumps
- prevent converting hangeul to unicode
"""
with _vp_warnings.catch_warnings():
_vp_warnings.simplefilter(action='ignore', category=FutureWarning)
print(_vp_json.dumps(command, ensure_ascii=False, cls=_VpNpEncoder))