def add_item(self, alias, item):
        """
        Add a config item to this section.
        """
        if not isinstance(alias, six.string_types):
            raise TypeError('Item name must be a string, got a {!r}'.format(type(alias)))
        item = copy.deepcopy(item)
        if item.name is not_set:
            item.name = alias

        if self.settings.str_path_separator in item.name:
            raise ValueError(
                'Item name must not contain str_path_separator which is configured for this Config -- {!r} -- '
                'but {!r} does.'.format(self.settings.str_path_separator, item)
            )

        self._tree[item.name] = item

        if item.name != alias:
            if self.settings.str_path_separator in alias:
                raise ValueError(
                    'Item alias must not contain str_path_separator which is configured for this Config -- {!r} --'
                    'but {!r} used for {!r} does.'.format(self.settings.str_path_separator, alias, item)
                )
            self._tree[alias] = item

        item._section = self

        self.dispatch_event(self.hooks.item_added_to_section, alias=alias, section=self, subject=item)
def add_item ( self , alias , item ) : if not isinstance ( alias , six . string_types ) : raise TypeError ( 'Item name must be a string, got a {!r}' . format ( type ( alias ) ) ) item = copy . deepcopy ( item ) if item . name is not_set : item . name = alias if self . settings . str_path_separator in item . name : raise ValueError ( 'Item name must not contain str_path_separator which is configured for this Config -- {!r} -- ' 'but {!r} does.' . format ( self . settings . str_path_separator , item ) ) self . _tree [ item . name ] = item if item . name != alias : if self . settings . str_path_separator in alias : raise ValueError ( 'Item alias must not contain str_path_separator which is configured for this Config -- {!r} --' 'but {!r} used for {!r} does.' . format ( self . settings . str_path_separator , alias , item ) ) self . _tree [ alias ] = item item . _section = self self . dispatch_event ( self . hooks . item_added_to_section , alias = alias , section = self , subject = item )
Add a config item to this section.