comparison src/cagou/core/cagou_main.py @ 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 ba14b596b90e
children d09bd16dbbe2
comparison
equal deleted inserted replaced
18:790dbc5c4e89 19:c58b522607f4
80 self.app.run() 80 self.app.run()
81 81
82 def _defaultFactory(self, plugin_info, target, profiles): 82 def _defaultFactory(self, plugin_info, target, profiles):
83 """factory used to create widget instance when PLUGIN_INFO["factory"] is not set""" 83 """factory used to create widget instance when PLUGIN_INFO["factory"] is not set"""
84 main_cls = plugin_info['main'] 84 main_cls = plugin_info['main']
85 return self.widgets.getOrCreateWidget(main_cls, target, on_new_widget=None, profiles=profiles) 85 return self.widgets.getOrCreateWidget(main_cls, target, on_new_widget=None, profiles=iter(self.profiles))
86 86
87 def _import_kv(self): 87 def _import_kv(self):
88 """import all kv files in cagou.kv""" 88 """import all kv files in cagou.kv"""
89 path = os.path.dirname(cagou.kv.__file__) 89 path = os.path.dirname(cagou.kv.__file__)
90 for kv_path in glob.glob(os.path.join(path, "*.kv")): 90 for kv_path in glob.glob(os.path.join(path, "*.kv")):
152 152
153 @param except_cls(None, class): if not None, 153 @param except_cls(None, class): if not None,
154 widgets from this class will be excluded 154 widgets from this class will be excluded
155 @return (list[dict]): available widgets plugin infos 155 @return (list[dict]): available widgets plugin infos
156 """ 156 """
157 lst = self._plg_wids[:] 157 for plugin_data in self._plg_wids:
158 if except_cls is not None: 158 if plugin_data['main'] == except_cls:
159 for plugin_info in lst: 159 continue
160 if plugin_info['main'] == except_cls: 160 yield plugin_data
161 lst.remove(plugin_info)
162 break
163 return lst
164 161
165 def plugging_profiles(self): 162 def plugging_profiles(self):
166 self.app.root.change_widgets([WidgetsHandler()]) 163 self.app.root.change_widgets([WidgetsHandler()])
167 164
168 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): 165 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE):