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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [4997a22651]

Overview
Comment:Fix conf.debug checking.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4997a22651d918bad8a8218aec79209fe98cff37
User & Date: mario on 2015-04-01 15:44:31
Other Links: manifest | tags
Context
2015-04-01
15:45
Split extension_main and extension_context menus. Fix pixmap icon back. check-in: 04f454a7a3 user: mario tags: trunk
15:44
Fix conf.debug checking. check-in: 4997a22651 user: mario tags: trunk
15:43
Nicer error message, and compacter plugin comment. Add default config value in init. check-in: 6226dc5594 user: mario tags: trunk
Changes

Modified config.py from [799d76f2f1] to [a316308630].

121
122
123
124
125
126
127

128
129
130
131
132
133
134
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135







+







        for opt in config:
            if ("name" in opt) and ("value" in opt) and (opt["name"] not in vars(self)):
                self.__dict__[opt["name"]] = opt["value"]

        # plugin state
        if module and module not in conf.plugins:
             conf.plugins[module] = 1
             #@TODO: use meta["priority"] in ("core", "builtin", "default") etc.

    
        
    # http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html
    def xdg(self, path="/streamtuner2"):
        home = os.environ.get("HOME", self.tmp)
        config = os.environ.get("XDG_CONFIG_HOME", os.environ.get("APPDATA", home+"/.config"))
185
186
187
188
189
190
191
192

193
194
195
196
197
198
199
186
187
188
189
190
191
192

193
194
195
196
197
198
199
200







-
+







            else:
                return # file not found
            # decode
            r = json.load(f)
            f.close()
            return r
        except Exception as e:
            print(dbg.ERR, "JSON parsing error (in "+name+")", e)
            __print__(dbg.ERR, "JSON 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)
301
302
303
304
305
306
307
308

309
310
311
312
313
314
315
316
317
318
319
320
321

322
323
324
325
326
327
328
302
303
304
305
306
307
308

309
310
311
312
313
314
315
316
317
318
319
320
321

322
323
324
325
326
327
328
329







-
+












-
+







    keyval  = re.compile(r"""
        ^([\w-]+):(.*$(?:\n(?![\w-]+:).+$)*)      # plain key:value lines
    """, re.M|re.X)
    config  = re.compile(r"""
        [\{\<] (.+?) [\}\>]                    # JSOL/YAML scheme {...} dicts
    """, re.X)
    options = re.compile(r"""
        ["':$]?   (\w+)  ["']?                 # key or ":key" or '$key'
        ["':$]?   (\w*)  ["']?                 # key or ":key" or '$key'
        \s* [:=] \s*                           # "=" or ":"
     (?:  "  ([^"]*)  " 
       |  '  ([^']*)  '                        #  "quoted" or 'singl' values
       |     ([^,]*)                           #  or unquoted literals
     )
    """, re.X)




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


# error colorization
dbg = type('obj', (object,), {
    "ERR":  r"[ERR]",  # red    ERROR
    "INIT": r"[INIT]", # red    INIT ERROR