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

⌈⌋ branch:  streamtuner2


Check-in [30dd0c5b1f]

Overview
Comment:Got rid of switchy() expression, use plain `cond and val or ...` chain.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 30dd0c5b1fcda5c2205c3692c1e53e7d9d082bf6
User & Date: mario on 2015-04-07 19:48:01
Other Links: manifest | tags
Context
2015-04-07
19:48
Fix main. references from bookmarks callback. check-in: 5a772b3c64 user: mario tags: trunk
19:48
Got rid of switchy() expression, use plain `cond and val or ...` chain. check-in: 30dd0c5b1f user: mario tags: trunk
05:55
Temporary export mechanism (saves whole category into .pls file). check-in: 8b7b270591 user: mario tags: trunk
Changes

Modified config.py from [ca9c88608a] to [ad58239673].

315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
        nargs  = re.findall("\\b\d+\\b|[\?\*\+]", opt["type"]) or [None]
        is_arr = "[]" in (naming + typing) and nargs == [None]
        is_bool= "bool" in typing
        false_b = "false" in typing or opt["value"] in ("0", "false")
        #print "\nname=", name, "is_arr=", is_arr, "is_bool=", is_bool, "bool_d=", false_b, "naming=", naming, "typing=", typing

        # Populate partially - ArgumentParser has aversions to many parameter combinations
        kwargs = {
            "args": args,
            "dest": name[0] if not name[0] in args else None,
            "action": self.sw( {is_arr: "append"}, {is_bool and false_b: "store_false"}, {is_bool: "store_true"}, {1: "store"} ),
            "nargs": nargs[0],
            "default": opt.get("default") or opt["value"],
            "type":  self.sw( {is_bool: None}, {"int" in typing: int}, {"bool" in typing: bool}, {1: str} ),
            "choices": opt["select"].split("|") if "select" in opt else None,
            "required": "required" in opt or None,
            "help": opt["description"] if not "hidden" in opt else argparse.SUPPRESS,
        }
        return {k:w for k,w in kwargs.items() if w is not None}


    # Shorthand switch, returns first value for cond==true from list of {cond:val} arguments
    def sw(self, *args):
        for pair in args:
            [(cond,val)] = pair.items()
            if cond:
                return val


# Retrieve content from install path or pyzip archive (alias for pkgutil.get_data)
#
def get_data(fn, decode=False, gz=False, file_base="config"):
    try:
        bin = pkgutil.get_data(file_base, fn)
        if gz:







|
|
|
|
|
|
|
|
|
|
<
<
|
|
<
<
<
<
<
<








315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331


332
333






334
335
336
337
338
339
340
341
        nargs  = re.findall("\\b\d+\\b|[\?\*\+]", opt["type"]) or [None]
        is_arr = "[]" in (naming + typing) and nargs == [None]
        is_bool= "bool" in typing
        false_b = "false" in typing or opt["value"] in ("0", "false")
        #print "\nname=", name, "is_arr=", is_arr, "is_bool=", is_bool, "bool_d=", false_b, "naming=", naming, "typing=", typing

        # Populate partially - ArgumentParser has aversions to many parameter combinations
        kwargs = dict(
            args     = args,
            dest     = name[0] if not name[0] in args else None,
            action   = is_arr and "append"  or  is_bool and false_b and "store_false"  or  is_bool and "store_true"  or  "store",
            nargs    = nargs[0],
            default  = opt.get("default") or opt["value"],
            type     = None if is_bool  else  ("int" in typing and int  or  "bool" in typing and bool  or  str),
            choices  = opt["select"].split("|") if "select" in opt else None,
            required = "required" in opt or None,
            help     = opt["description"] if not "hidden" in opt else argparse.SUPPRESS


        )
        return {k:w for k,w in kwargs.items() if w is not None}








# Retrieve content from install path or pyzip archive (alias for pkgutil.get_data)
#
def get_data(fn, decode=False, gz=False, file_base="config"):
    try:
        bin = pkgutil.get_data(file_base, fn)
        if gz: