示例#1
0
 def __contains__(self, name):
     if not name in self._aliases:
         try:
             plugin(name, self._group)
         except:
             return False
         else:
             return True
     else:
         return True
示例#2
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')
示例#3
0
 def set_applet(self, applet):
     self._applet = weakref.ref(applet)
     self._layout.insertWidget(1, applet)
     _plugin = plugin(applet.name, 'oalab.applet')
     self._l_title.setText(_plugin.label)
     p = QtGui.QSizePolicy
     applet.setSizePolicy(p(p.MinimumExpanding, p.MinimumExpanding))
示例#4
0
def node_factory(plugin_name, group=None, name=None, category=None):
    _plugin = plugin(plugin_name, group=group)
    name = name if name else _plugin.name
    factory = Factory(name=name, category=category,
                      inputs=_plugin.inputs, outputs=_plugin.outputs,
                      nodemodule=_plugin.modulename,
                      nodeclass=_plugin.objectname,
                      )
    return factory
示例#5
0
    def _redraw_tab(self, idx):
        """
        """
        if idx not in self._name:
            return

        name = self._name[idx]
        pl = plugin(name, 'oalab.applet')
        applet = self._applets[idx][name]
        # self.setTabText(idx, _plugin_class.label)
        if self.tabPosition() == QtGui.QTabWidget.East:
            rotation = -90
        elif tabposition_int(self.tabPosition()) == 2:
            rotation = 90
        else:
            rotation = 0

        self.setTabIcon(idx, obj_icon([pl, applet], rotation=rotation))
        self.setTabToolTip(idx, pl.label)
        self.widget(idx).set_edit_mode(self._edit_mode)
示例#6
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')
示例#7
0
 def __getitem__(self, name):
     if name in self._aliases:
         name = self._aliases[name]
     return plugin(name, self._group) # Get the plugin class