Index: pluginconf.py ================================================================== --- pluginconf.py +++ pluginconf.py @@ -2,11 +2,11 @@ # api: python # type: extract # category: io # title: Plugin configuration # description: Read meta data, pyz/package contents, module locating -# version: 0.7.0 +# version: 0.7.1 # priority: core # docs: https://fossil.include-once.org/pluginspec/ # url: http://fossil.include-once.org/streamtuner2/wiki/plugin+meta+data # config: - # @@ -295,13 +295,30 @@ "description": "", "value": None } for field in rx.options.findall(entry): opt[field[0]] = (field[1] or field[2] or field[3] or "").strip() - #@todo map type: + # normalize type + opt["type"] = config_opt_type_map.get(opt["type"], opt["type"] or "str") + # preparse select: + if opt.get("select"): + opt["select"] = config_opt_parse_select(opt.get("select", "")) config.append(opt) return config + +# split up `select: 1=on|2=more|3=title` or `select: foo|bar|lists` +def config_opt_parse_select(s): + if re.search("([=:])", s): + return dict(rx.select_dict.findall(s)) + else: + return dict([(v, v) for v in rx.select_list.findall(s)]) + +# normalize type:names to `str`, `bool`, `int`, `select`, `dict` +config_opt_type_map = dict( + text="str", string="str", boolean="bool", checkbox="bool", integer="int", number="int", + choice="select", options="select", table="dict", array="dict" +) # Comment extraction regexps # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # Pretty crude comment splitting approach. But works @@ -323,10 +340,13 @@ (?: " ([^"]*) " | ' ([^']*) ' # "quoted" or 'singl' values | ([^,]*) # or unquoted literals ) """, re.X) + select_dict = re.compile("(\w+)\s*[=:>]+\s*([^=,|:]+)") + select_list = re.compile("\s*([^,|;]+)\s*") + # ArgumentParser options conversion # ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ # As variation of in-application config: options, this method converts Index: uikit.py ================================================================== --- uikit.py +++ uikit.py @@ -702,10 +702,11 @@ self.connect("scroll_event", self.no_scroll) # collect entries self.ls = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) self.set_model(self.ls) + entries = entries.items() if type(entries[0]) is not tuple: entries = zip(entries, entries) for key,value in entries: self.ls.append([key, value])