12
13
14
15
16
17
18
19
20
21
22
23
24
25 | # This module provides the JSON api. If the python 2.6 module
# isn't available, it provides an emulation using str() and
# eval() and Python notation. (The representations are close.)
#
# Additionally it filters out any left-over objects. Sometimes
# 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
from compat2and3 import unicode |
>
>
>
>
>
| 12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 | # This module provides the JSON api. If the python 2.6 module
# isn't available, it provides an emulation using str() and
# eval() and Python notation. (The representations are close.)
#
# Additionally it filters out any left-over objects. Sometimes
# pygtk-objects crawled into the streams[] lists, because rows
# might have been queried from the widgets.
# (Need to find out if that still happens..)
#
# filter_data should become redundant, as mygtk.columns now
# converts unicode to str in Py2. And since we depend on Py2.7
# anway the JSON-like Python serialization should be dropped.
#
#-- reading and writing json (for the config module) ----------------------------------
import sys
from compat2and3 import unicode |
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71 |
# load from filepointer, decode string into dicts/list
def load(fp):
try:
#print("try json")
r = json_load(fp)
r = filter_data(r) # turn unicode() strings back into str() - pygtk does not accept u"strings"
except:
#print("fall back on pson")
fp.seek(0)
r = eval(fp.read(1<<27)) # max 128 MB
# print("fake json module: in python variable dump notation")
if r == None: |
|
| 62
63
64
65
66
67
68
69
70
71
72
73
74
75
76 |
# load from filepointer, decode string into dicts/list
def load(fp):
try:
#print("try json")
r = json_load(fp)
# r = filter_data(r) # turn unicode() strings back into str() - pygtk does not accept u"strings"
except:
#print("fall back on pson")
fp.seek(0)
r = eval(fp.read(1<<27)) # max 128 MB
# print("fake json module: in python variable dump notation")
if r == None: |