-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_utils.py
More file actions
31 lines (26 loc) · 762 Bytes
/
_utils.py
File metadata and controls
31 lines (26 loc) · 762 Bytes
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
import json
import datetime
import _model
def __JsonDefault(obj):
if isinstance(obj, datetime.datetime) :
return obj.strftime('%Y-%m-%dT%H:%M:%S')
elif isinstance(obj, datetime.date) :
return obj.strftime('%Y-%m-%d')
elif isinstance(obj, _model.Object) :
return obj.__dict__
else:
raise TypeError('%r is not JSON serializable' % obj)
def formatObject(obj) :
return json.dumps(obj, ensure_ascii=False, indent=2, default = __JsonDefault)
def printByteStr(encodeStr) :
if not encodeStr :
return
outstr = ''
col = 0
for c in encodeStr :
outstr += '%02x ' % (ord(c))
col += 1
if col >= 16 :
col = 0
outstr += '\n'
print outstr