def __setitem__(self, name, value): if isinstance(value, six.string_types): value = plugin(value, self._group).identifier self._aliases[name] = value self.__class__.plugin = property(get_plugin, set_plugin, doc=plugin_doc(self)) elif inspect.isclass(value): if len(self._tags) == 0 and not hasattr(value, 'tags'): value.tags = [] for tag in self._tags: if tag not in value.tags: raise ValueError('\'value\' parameter: missing tag \'' + tag + '\'') for criterion in self._criteria: if not hasattr(value, criterion): raise ValueError( '\'value\' parameter: missing criterion \'' + criterion + '\'') elif not getattr(value, criterion) == self._criteria[criterion]: raise ValueError('\'value\' parameter: criterion \'' + criterion + '\' not equal to \'' + self._criteria[criterion] + '\'') value = register_plugin(value, self._group).identifier # Add a plugin if name is not None: self[name] = value # Get the plugin unique name self.__class__.plugin = property(get_plugin, set_plugin, doc=plugin_doc(self)) else: raise TypeError('\'plugin\' parameter')
def __setitem__(self, name, value): if isinstance(value, basestring): value = plugin(value, self._group).identifier self._aliases[name] = value self.__class__.plugin = property(get_plugin, set_plugin, doc=plugin_doc(self)) elif inspect.isclass(value): if len(self._tags) == 0 and not hasattr(value, 'tags'): value.tags = [] for tag in self._tags: if tag not in value.tags: raise ValueError('\'value\' parameter: missing tag \'' + tag + '\'') for criterion in self._criteria: if not hasattr(value, criterion): raise ValueError('\'value\' parameter: missing criterion \'' + criterion + '\'') elif not getattr(value, criterion) == self._criteria[criterion]: raise ValueError('\'value\' parameter: criterion \'' + criterion + '\' not equal to \'' + self._criteria[criterion] + '\'') value = register_plugin(value, self._group).identifier # Add a plugin if name is not None: self[name] = value # Get the plugin unique name self.__class__.plugin = property(get_plugin, set_plugin, doc=plugin_doc(self)) else: raise TypeError('\'plugin\' parameter')
return data, {} def encode(self, data, mimetype_in, mimetype_out): return mimetype_out, '%s;%s' % (data.num, data.letter) class SampleCustomDataCodecPlugin(QMimeCodecPlugin): qtencode = [ ("custom/data", "custom/data"), ] qtdecode = [ ("custom/data", "custom/data"), ("custom/data", "openalealab/control"), ("custom/data", "text/plain"), ("custom/data", "text/plain.verbose"), ] mimetype_desc = { 'text/plain': dict(title='Short Text'), 'text/plain.verbose': dict(title='Long Text'), 'custom/data': dict(title='Custom data'), 'openalealab/control': dict(title='Control'), } def __call__(self): return SampleCustomDataCodec register_plugin(SampleCustomDataCodecPlugin, 'oalab.plugin') reload_drag_and_drop_plugins()
return [self.menu_edit, self.action_menu_1] def initialize(self): print "initialize", self class TestAppletPlugin(object): name = 'TestApplet' label = 'Test Applet' def __call__(self): return TestApplet from openalea.core.service.plugin import register_plugin, plugins from openalea.core.util import camel_case_to_lower register_plugin(TestAppletPlugin, 'oalab.applet') if __name__ == '__main__': SAMPLE_WIDGET = 'FileBrowser' sample_widget = camel_case_to_lower(SAMPLE_WIDGET) def hello_world(): print 'Hello OpenAleaLab world' def change_applet(applet_name='TestApplet'): widget = ns[sample_widget] widget.parent_tab.set_applet(applet_name) test_applet(SAMPLE_WIDGET, tests=[hello_world, change_applet])
def initialize(self): print "initialize", self class TestAppletPlugin(object): name = "TestApplet" label = "Test Applet" def __call__(self): return TestApplet from openalea.core.service.plugin import register_plugin, plugins from openalea.core.util import camel_case_to_lower register_plugin(TestAppletPlugin, "oalab.applet") if __name__ == "__main__": SAMPLE_WIDGET = "FileBrowser" sample_widget = camel_case_to_lower(SAMPLE_WIDGET) def hello_world(): print "Hello OpenAleaLab world" def change_applet(applet_name="TestApplet"): widget = ns[sample_widget] widget.parent_tab.set_applet(applet_name) test_applet(SAMPLE_WIDGET, tests=[hello_world, change_applet])