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

⌈⌋ ⎇ branch:  streamtuner2


Diff

Differences From Artifact [0a6d293594]:

To Artifact [16fe14f094]:


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
conf = object()



#-- global configuration data               ---------------------------------------------
class ConfigDict(dict):


        # start
        def __init__(self):
        
            # object==dict means conf.var is conf["var"]
            self.__dict__ = self  # let's pray this won't leak memory due to recursion issues

            # prepare







<







26
27
28
29
30
31
32

33
34
35
36
37
38
39
conf = object()



#-- global configuration data               ---------------------------------------------
class ConfigDict(dict):


        # start
        def __init__(self):
        
            # object==dict means conf.var is conf["var"]
            self.__dict__ = self  # let's pray this won't leak memory due to recursion issues

            # prepare
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192




















                    f = open(file, "r")
                else:
                    return # file not found
                # decode
                r = pson.load(f)
                f.close()
                return r
            except (Exception), e:
                print("PSON parsing error (in "+name+")", e)
            

        # recursive dict update
        def update(self, with_new_data):
            for key,value in with_new_data.iteritems():
                if type(value) == dict:
                    self[key].update(value)
                else:
                    self[key] = value
            # descends into sub-dicts instead of wiping them with subkeys

             
        # check for existing filename in directory list
        def find_in_dirs(self, dirs, file):
            for d in dirs:
                if os.path.exists(d+"/"+file):
                    return d+"/"+file


   
#-- actually fill global conf instance
conf = ConfigDict()































|





|





















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
                    f = open(file, "r")
                else:
                    return # file not found
                # decode
                r = pson.load(f)
                f.close()
                return r
            except Exception as e:
                print("PSON parsing error (in "+name+")", e)
            

        # recursive dict update
        def update(self, with_new_data):
            for key,value in with_new_data.items():
                if type(value) == dict:
                    self[key].update(value)
                else:
                    self[key] = value
            # descends into sub-dicts instead of wiping them with subkeys

             
        # check for existing filename in directory list
        def find_in_dirs(self, dirs, file):
            for d in dirs:
                if os.path.exists(d+"/"+file):
                    return d+"/"+file


   
#-- actually fill global conf instance
conf = ConfigDict()




# wrapper for all print statements
def __print__(*args):
    if conf.debug:
        print(" ".join([str(a) for a in args]))


# error colorization
dbg = type('obj', (object,), {
    "ERR":  "[ERR]",  # red    ERROR
    "INIT": "[INIT]", # red    INIT ERROR
    "PROC": "[PROC]", # green  PROCESS
    "CONF": "[CONF]", # brown  CONFIG DATA
    "UI":   "[UI]",   # blue   USER INTERFACE BEHAVIOUR
    "HTTP": "[HTTP]", # magenta HTTP REQUEST
    "DATA": "[DATA]", # cyan   DATA
    "INFO": "[INFO]", # gray   INFO
    "STAT": "[STATE]", # gray  CONFIG STATE
})