예제 #1
0
 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')
예제 #2
0
파일: functor.py 프로젝트: gbaty/openalea
 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')
예제 #3
0
파일: mimedata.py 프로젝트: gbaty/openalea
        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()
예제 #4
0
        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])
예제 #5
0
        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()
예제 #6
0
    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])