Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ ⎇ branch:  streamtuner2


Diff

Differences From Artifact [759da668d2]:

To Artifact [6186b9e864]:

  • File pson.py — part of check-in [1beab0563e] at 2014-04-10 04:31:02 on branch py3 — * Fixed gtk_list_store_get_value: assertion `column < list_store->n_columns' by removing {width:20} reference from treeview datamap. * row.setdefault() for absent search_col/set and deleted state * More __print__/dbg colorization * Disabled pson.filter_data in favour of str casting in mygtk.columns() * Removed streamactions.popup PY2/PY3 workaround with named args * More .iteritems() removal (user: mario, size: 3399) [annotate] [blame] [check-ins using]

12
13
14
15
16
17
18





19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#  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
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")








>
>
>
>
>






<
|
<







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

30

31
32
33
34
35
36
37
#  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


# 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")

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73


# 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: