Mercurial > libervia-desktop-kivy
comparison 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 |
comparison
equal
deleted
inserted
replaced
40:a1ec6cb57a1b | 41:7cac2d1a6f20 |
---|---|
304 def getPluggedWidgets(self, except_cls=None): | 304 def getPluggedWidgets(self, except_cls=None): |
305 """get available widgets plugin infos | 305 """get available widgets plugin infos |
306 | 306 |
307 @param except_cls(None, class): if not None, | 307 @param except_cls(None, class): if not None, |
308 widgets from this class will be excluded | 308 widgets from this class will be excluded |
309 @return (list[dict]): available widgets plugin infos | 309 @return (iter[dict]): available widgets plugin infos |
310 """ | 310 """ |
311 for plugin_data in self._plg_wids: | 311 for plugin_data in self._plg_wids: |
312 if plugin_data['main'] == except_cls: | 312 if plugin_data['main'] == except_cls: |
313 continue | 313 continue |
314 yield plugin_data | 314 yield plugin_data |
315 | |
316 def getPluginInfo(self, **kwargs): | |
317 """get first plugin info corresponding to filters | |
318 | |
319 @param **kwargs: filter(s) to use, each key present here must also | |
320 exist and be of the same value in requested plugin info | |
321 @return (dict, None): found plugin info or None | |
322 """ | |
323 for plugin_info in self._plg_wids: | |
324 for k, w in kwargs.iteritems(): | |
325 try: | |
326 if plugin_info[k] != w: | |
327 continue | |
328 except KeyError: | |
329 continue | |
330 return plugin_info | |
315 | 331 |
316 ## widgets handling | 332 ## widgets handling |
317 | 333 |
318 def getParentHandler(self, widget): | 334 def getParentHandler(self, widget): |
319 """Return handler holding this widget | 335 """Return handler holding this widget |