17
18
19
20
21
22
23
24
25
26
27
28
29
30 | # pygtk-objects crawled into the streams[] lists, because rows
# might have been queried from the widgets.
#
#-- reading and writing json (for the config module) ----------------------------------
# try to load the system module first
try:
from json import dump as json_dump, load as json_load
except:
print("no native Python JSON module")
|
>
>
>
>
| 17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 | # pygtk-objects crawled into the streams[] lists, because rows
# might have been queried from the widgets.
#
#-- reading and writing json (for the config module) ----------------------------------
import sys
if sys.version_info > (2, 9):
unicode = str
#dict.iteritems = dict.items
# try to load the system module first
try:
from json import dump as json_dump, load as json_load
except:
print("no native Python JSON module")
|
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96 | elif type(obj) == unicode:
return str(obj)
elif type(obj) in (list, tuple, set):
obj = list(obj)
for i,v in enumerate(obj):
obj[i] = filter_data(v)
elif type(obj) == dict:
for i,v in obj.iteritems():
i = filter_data(i)
obj[i] = filter_data(v)
else:
print("invalid object in data, converting to string: ", type(obj), obj)
obj = str(obj)
return obj
|
|
| 84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100 | elif type(obj) == unicode:
return str(obj)
elif type(obj) in (list, tuple, set):
obj = list(obj)
for i,v in enumerate(obj):
obj[i] = filter_data(v)
elif type(obj) == dict:
for i,v in list(obj.items()):
i = filter_data(i)
obj[i] = filter_data(v)
else:
print("invalid object in data, converting to string: ", type(obj), obj)
obj = str(obj)
return obj
|