def new(self, name, protocol, override=False, register_magics=True, **kwargs): """ Create a new service and register it into the registry. Args: name (str): The name (or names) of the target service. If multiple aliases are to be used, names should be a comma separated list. See `.register` for more details. protocol (str): The protocol of the new service. override (bool): Whether to override any existing `Duct` instance of the same name. If `False`, any overrides will result in an exception. register_magics (bool): Whether to register the magics if running in and IPython session (default: `True`). **kwargs (dict): Additional arguments to pass to the constructor of the class associated with the nominated protocol. Returns: Duct: The `Duct` instance registered into the registry. """ return self.register(Duct.for_protocol(protocol)( name=name.split(',')[0].strip(), registry=self, **kwargs), name=name, override=override, register_magics=register_magics)
def new(self, names, protocol, register_magics=True, **options): if isinstance(names, six.string_types): names = names.split(',') duct = Duct.for_protocol(protocol)(name=names[0], registry=self, **options) for name in names: self.register(duct, name=name) if register_magics and isinstance(duct, MagicsProvider): duct.register_magics(base_name=name) return duct