Index: channels/pluginmanager2.py ================================================================== --- channels/pluginmanager2.py +++ channels/pluginmanager2.py @@ -26,10 +26,11 @@ # makes this handler look complicated. import imp import config +import pluginconf import pkgutil from channels import __path__ as channels__path__ import os from config import * from uikit import * @@ -126,26 +127,16 @@ self.parent.status() # Clean up placeholders in vbox _ = [self.vbox.remove(c) for c in self.vbox.get_children()[3:]] - # Query existing plugins - dep = dependency() - # Attach available downloads + # Attach available downloads after checking dependencies + # e.g. newpl["depends"] = "streamtuner2 < 2.2.0, config >= 2.5" + dep = pluginconf.dependency() for newpl in meta: - id = newpl.get("$name") - # skip __init__.py - if id.find("__") == 0: - continue - # exclude if newer/current version already installed - if dep.have.get(id) and dep.have[id]["version"] >= newpl.get("version"): - continue - # check dependencies - #newpl["depends"] = "streamtuner2 < 2.2.0, config >= 2.5" - if not dep.depends(newpl): - continue - self.add_plugin(newpl) + if dep.valid(newpl) and dep.depends(newpl): + self.add_plugin(newpl) # Readd some filler labels _ = [self.add_(uikit.label("")) for i in range(1,3)] @@ -155,11 +146,11 @@ p = self.update_p(p) text = "$title, "\ "version: $version, "\ "type: $type "\ "category: $category\n"\ - "$description\n"\ + "$description\n"\ "$extras, view src" self.add_(b, safe_format(text, **p), markup=1) # Add placeholder fields @@ -208,67 +199,11 @@ # just let main load any new plugins p.load_plugin_channels() - -# Do minimal depends: probing -class dependency(object): - - # prepare list of known plugins and versions - def __init__(self): - self.have = {name: plugin_meta(module=name) for name in module_list()} - # dependencies on core modules are somewhat more interesting: - self.have.update({ - "streamtuner2": plugin_meta(module="st2", plugin_base=["config"]), - "uikit": plugin_meta(module="uikit", plugin_base=["config"]), - "config": plugin_meta(module="config", plugin_base=["config"]), - "action": plugin_meta(module="action", plugin_base=["config"]), - }) - have = {} - - # depends: - def depends(self, plugin): - if plugin.get("depends"): - d = self.deps(plugin["depends"]) - if not self.cmp(d, self.have): - return False - return True - - # Split trivial "pkg, mod >= 1, uikit < 4.0" list - def deps(self, dep_str): - d = [] - for dep in re.split(r"\s*[,;]+\s*", dep_str): - # skip deb:pkg-name, rpm:name, bin:name etc. - if not len(dep) or dep.find(":") >= 0: - continue - # find comparison and version num - m = re.search(r"([\w.-]+)\s*([>== 0") - if m and m.group(2): - d.append([m.group(i) for i in (1,2,3)]) - return d - - # Do actual comparison - def cmp(self, d, have): - r = True - for name, op, ver in d: - # skip unknown plugins, might be python module references ("depends: re, json") - if not have.get(name, {}).get("version"): - continue - curr = have[name]["version"] - tbl = { - ">=": curr >= ver, - "<=": curr <= ver, - "==": curr == ver, - ">": curr > ver, - "<": curr < ver, - "!=": curr != ver, - } - r &= tbl.get(op, True) - return r - # Alternative to .format(), with keys possibly being absent from string import Template def safe_format(str, **kwargs): return Template(str).safe_substitute(**kwargs) Index: st2.py ================================================================== --- st2.py +++ st2.py @@ -350,11 +350,10 @@ cn.save() # Alternative Notebook channel tabs between TOP and LEFT position def switch_notebook_tabs_position(self, w, pos): self.notebook_channels.set_tab_pos(pos); - # Shortcut to statusbar and progressbar (receives either a string, or a float).