Example #1
0
def add_factory(pkg, fct, base_dir=None):
    """
    Add a (Node) Factory for function `fct` into package `pkg`
    
    If function does not contain suitable meta_info, try to take it from `pkg_info`
    """
    s = Signature(fct)
    base_dir = [base_dir] if base_dir else None
    
    fac = Factory(s.name, description=s.get_doc(), inputs=s.parameters, outputs=None,
                  nodemodule=fct.__module__, nodeclass=s.name, search_path=base_dir, authors=pkg.metainfo.get('authors',None))
        ##, category='', widgetmodule=None, widgetclass=None, **kargs

    pkg[s.name] = fac
    def set_method_name(self, name):
        instance = self.get_input(0)
        if instance is not None and name is not None:
            meth = getattr(instance, name, None)
            if meth:
                sig = Signature(meth)
                inputs = sig.get_all_parameters()
                prefix = type(instance).__name__ if not hasattr(instance, "__name__") \
                         else instance.__name__
                if len(prefix) > 15:
                    prefix = prefix[:5] + "..." + prefix[-5:]
                self.set_caption(prefix + " : " + name)

                # self.set_caption(name)
                self.internal_data["methodName"] = name
                self.internal_data["methodSig"] = inputs
                self.__doc__ = sig.get_doc()
                self.build_ports(inputs)
    def set_method_name(self, name):
        instance = self.get_input(0)
        if instance is not None and name is not None:
            meth = getattr(instance, name, None)
            if meth:
                sig = Signature(meth)
                inputs = sig.get_all_parameters()
                prefix = type(instance).__name__ if not hasattr(instance, "__name__") \
                         else instance.__name__
                if len(prefix)>15:
                    prefix = prefix[:5]+"..."+prefix[-5:]
                self.set_caption(prefix+" : "+name)

                # self.set_caption(name)
                self.internal_data["methodName"] = name
                self.internal_data["methodSig"] = inputs
                self.__doc__ = sig.get_doc()
                self.build_ports(inputs)
Example #4
0
def add_factory(pkg, fct, base_dir=None):
    """
    Add a (Node) Factory for function `fct` into package `pkg`
    
    If function does not contain suitable meta_info, try to take it from `pkg_info`
    """
    s = Signature(fct)
    base_dir = [base_dir] if base_dir else None

    fac = Factory(
        s.name,
        description=s.get_doc(),
        inputs=s.parameters,
        outputs=None,
        nodemodule=fct.__module__,
        nodeclass=s.name,
        search_path=base_dir,
        authors=pkg.metainfo.get("authors", None),
    )
    ##, category='', widgetmodule=None, widgetclass=None, **kargs

    pkg[s.name] = fac