remotelogin/devices/managers/base.py
def add(self, name_or_instance, set_as_default=False, **kwargs):
        """ add an item to the device.

            Args:
                name_or_instance (str or cls): the name of the item or an instance
                set_as_default (bool): flag to indicate that we want this item to be the default to be used by
                                       connections without item name
                kwargs (dict): arguments to pass to cls if creating a new instance
        """
        with self.manager_lock:

            if not isinstance(name_or_instance, str) and not isinstance(name_or_instance, self.ItemCls):
                raise TypeError('The argument name_or_instance has to be a string '
                                '(the interface name) or an instance of an Interface class')

            name = name_or_instance.name if isinstance(name_or_instance, self.ItemCls) else name_or_instance.strip()

            if not name:
                raise ValueError('You cannot pass an empty value for name of Item')

            if name not in self._items:

                if isinstance(name_or_instance, self.ItemCls):
                    instance = name_or_instance
                else:
                    self.ItemCls.check_args_from_dict(kwargs)
                    instance = self.ItemCls(name=name, **kwargs)
                    self.check_item_unique(instance)

                if set_as_default or not self._items:
                    self._default_item_name = instance.name

                self._items[name] = instance
                return instance

            else:
                raise self.DuplicatedItemError('This name ({}) has already been used'.format(name))
 add an item to the device.

            Args:
                name_or_instance (str or cls): the name of the item or an instance
                set_as_default (bool): flag to indicate that we want this item to be the default to be used by
                                       connections without item name
                kwargs (dict): arguments to pass to cls if creating a new instance
        
add an item to the device.
add an item to the device .
def add(self, name_or_instance, set_as_default=False, **kwargs):
        with self.manager_lock:
            if not isinstance(name_or_instance, str) and not isinstance(name_or_instance, self.ItemCls):
                raise TypeError('The argument name_or_instance has to be a string '
                                '(the interface name) or an instance of an Interface class')
            name = name_or_instance.name if isinstance(name_or_instance, self.ItemCls) else name_or_instance.strip()
            if not name:
                raise ValueError('You cannot pass an empty value for name of Item')
            if name not in self._items:
                if isinstance(name_or_instance, self.ItemCls):
                    instance = name_or_instance
                else:
                    self.ItemCls.check_args_from_dict(kwargs)
                    instance = self.ItemCls(name=name, **kwargs)
                    self.check_item_unique(instance)
                if set_as_default or not self._items:
                    self._default_item_name = instance.name
                self._items[name] = instance
                return instance
            else:
                raise self.DuplicatedItemError('This name ({}) has already been used'.format(name))
def add ( self , name_or_instance , set_as_default = False , ** kwargs ) : with self . manager_lock : if not isinstance ( name_or_instance , str ) and not isinstance ( name_or_instance , self . ItemCls ) : raise TypeError ( 'The argument name_or_instance has to be a string ' '(the interface name) or an instance of an Interface class' ) name = name_or_instance . name if isinstance ( name_or_instance , self . ItemCls ) else name_or_instance . strip ( ) if not name : raise ValueError ( 'You cannot pass an empty value for name of Item' ) if name not in self . _items : if isinstance ( name_or_instance , self . ItemCls ) : instance = name_or_instance else : self . ItemCls . check_args_from_dict ( kwargs ) instance = self . ItemCls ( name = name , ** kwargs ) self . check_item_unique ( instance ) if set_as_default or not self . _items : self . _default_item_name = instance . name self . _items [ name ] = instance return instance else : raise self . DuplicatedItemError ( 'This name ({}) has already been used' . format ( name ) )
add an item to the device.
add an item to the device .
""" add an item to the device.

            Args:
                name_or_instance (str or cls): the name of the item or an instance
                set_as_default (bool): flag to indicate that we want this item to be the default to be used by
                                       connections without item name
                kwargs (dict): arguments to pass to cls if creating a new instance
        """
self
name_or_instance
the name of the item or an instance
the name of the item or an instance
set_as_default
flag to indicate that we want this item to be the default to be used by
connections without item name
flag to indicate that we want this item to be the default to be used by connections without item name
kwargs
arguments to pass to cls if creating a new instance
arguments to pass to cls if creating a new instance