def set(self, value):
        """
        Sets the value of the object

        :param value:
            An integer, or a unicode string if _map is set

        :raises:
            ValueError - when an invalid value is passed
        """

        if isinstance(value, str_cls):
            if self._map is None:
                raise ValueError(unwrap(
                    '''
                    %s value is a unicode string, but no _map provided
                    ''',
                    type_name(self)
                ))

            if value not in self._reverse_map:
                raise ValueError(unwrap(
                    '''
                    %s value, %s, is not present in the _map
                    ''',
                    type_name(self),
                    value
                ))

            value = self._reverse_map[value]

        elif not isinstance(value, int_types):
            raise TypeError(unwrap(
                '''
                %s value must be an integer or unicode string when a name_map
                is provided, not %s
                ''',
                type_name(self),
                type_name(value)
            ))

        self._native = self._map[value] if self._map and value in self._map else value

        self.contents = int_to_bytes(value, signed=True)
        self._header = None
        if self._trailer != b'':
            self._trailer = b''
def set ( self , value ) : if isinstance ( value , str_cls ) : if self . _map is None : raise ValueError ( unwrap ( '''
                    %s value is a unicode string, but no _map provided
                    ''' , type_name ( self ) ) ) if value not in self . _reverse_map : raise ValueError ( unwrap ( '''
                    %s value, %s, is not present in the _map
                    ''' , type_name ( self ) , value ) ) value = self . _reverse_map [ value ] elif not isinstance ( value , int_types ) : raise TypeError ( unwrap ( '''
                %s value must be an integer or unicode string when a name_map
                is provided, not %s
                ''' , type_name ( self ) , type_name ( value ) ) ) self . _native = self . _map [ value ] if self . _map and value in self . _map else value self . contents = int_to_bytes ( value , signed = True ) self . _header = None if self . _trailer != b'' : self . _trailer = b''
Sets the value of the object

        :param value:
            An integer, or a unicode string if _map is set

        :raises:
            ValueError - when an invalid value is passed