changeset 19:c58b522607f4

main: fixed profiles value in _defaultFactory + getPluggedWidgets is now a generator
author Goffi <goffi@goffi.org>
date Mon, 08 Aug 2016 00:58:59 +0200
parents 790dbc5c4e89
children 29b507826eed
files src/cagou/core/cagou_main.py
diffstat 1 files changed, 5 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/cagou/core/cagou_main.py	Mon Aug 08 00:54:11 2016 +0200
+++ b/src/cagou/core/cagou_main.py	Mon Aug 08 00:58:59 2016 +0200
@@ -82,7 +82,7 @@
     def _defaultFactory(self, plugin_info, target, profiles):
         """factory used to create widget instance when PLUGIN_INFO["factory"] is not set"""
         main_cls = plugin_info['main']
-        return self.widgets.getOrCreateWidget(main_cls, target, on_new_widget=None, profiles=profiles)
+        return self.widgets.getOrCreateWidget(main_cls, target, on_new_widget=None, profiles=iter(self.profiles))
 
     def _import_kv(self):
         """import all kv files in cagou.kv"""
@@ -154,13 +154,10 @@
             widgets from this class will be excluded
         @return (list[dict]): available widgets plugin infos
         """
-        lst = self._plg_wids[:]
-        if except_cls is not None:
-            for plugin_info in lst:
-                if plugin_info['main'] == except_cls:
-                    lst.remove(plugin_info)
-                    break
-        return lst
+        for plugin_data in self._plg_wids:
+            if plugin_data['main'] == except_cls:
+                continue
+            yield plugin_data
 
     def plugging_profiles(self):
         self.app.root.change_widgets([WidgetsHandler()])