Mercurial > libervia-desktop-kivy
diff src/cagou/core/cagou_main.py @ 41:7cac2d1a6f20
core: new getPluginInfo method to retrieve plugin info corresponding to filter(s)
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 28 Aug 2016 16:11:07 +0200 |
parents | a1ec6cb57a1b |
children | 12fdc7d1feb1 |
line wrap: on
line diff
--- a/src/cagou/core/cagou_main.py Sun Aug 28 15:37:22 2016 +0200 +++ b/src/cagou/core/cagou_main.py Sun Aug 28 16:11:07 2016 +0200 @@ -306,13 +306,29 @@ @param except_cls(None, class): if not None, widgets from this class will be excluded - @return (list[dict]): available widgets plugin infos + @return (iter[dict]): available widgets plugin infos """ for plugin_data in self._plg_wids: if plugin_data['main'] == except_cls: continue yield plugin_data + def getPluginInfo(self, **kwargs): + """get first plugin info corresponding to filters + + @param **kwargs: filter(s) to use, each key present here must also + exist and be of the same value in requested plugin info + @return (dict, None): found plugin info or None + """ + for plugin_info in self._plg_wids: + for k, w in kwargs.iteritems(): + try: + if plugin_info[k] != w: + continue + except KeyError: + continue + return plugin_info + ## widgets handling def getParentHandler(self, widget):