Try to decode data into a message, might return None if the data is invalid.
324349
def wrap(data):
    
    try:
        cmdid = data[0]
    except IndexError:
        log.warning('data is empty')
        return None

    try:
        message_type = CMDID_MESSAGE[cmdid]
    except KeyError:
        log.error('unknown cmdid %s', cmdid)
        return None

    try:
        message = message_type(data)
    except ValueError:
        log.error('trying to decode invalid message')
        return None

    return message
94558
def decode(self, data: bytes) -> bytes:
        
        if CONTENT_TRANSFER_ENCODING in self.headers:
            data = self._decode_content_transfer(data)
        if CONTENT_ENCODING in self.headers:
            return self._decode_content(data)
        return data
1012195
def decode_nullable(self, data_type, obj):
        
        if obj is not None:
            return self.json_compat_obj_decode_helper(data_type.validator, obj)
        else:
            return None
390888
def _decode(self, s):
        ''' '''
        if self.decoder is not None:
            return self.decoder.decode(s)
        else:
            raise TypeError("This screen was constructed with encoding=None, "
                            "so it does not handle bytes.")
437401
def decoded(self):
        
        logging.info("Decoding message: {0}".format(self.message))
        self.offset = self.offset * -1
        return self.cipher()
150286
def decode(data)
      return nil if data.nil? || data.strip.empty?
      decode_object(@load.call(data))
    end
80574
def __validate_decode_msg(self, message):  # noqa (complexity) pylint: disable=too-many-return-statements,too-many-branches
        """"""
        try:
            if not _CONTENT_TYPE_PATTERN.match(message.content_type):
                logger.debug('Message with unexpected content type %s from container, ignoring', message.content_type)
                return None
        except AttributeError:
            logger.debug('Message without content type from container, ignoring')
            return None

        # Decode & check message wrapper
        try:
            body = ubjloadb(message.body)
        except:
            logger.warning('Failed to decode message wrapper, ignoring', exc_info=DEBUG_ENABLED)
            return None
        if not self.__valid_msg_wrapper(body):
            logger.warning('Invalid message wrapper, ignoring')
            return None

        # currently only warn although maybe this should be an error
        if self.__cnt_seqnum != -1 and not self.__valid_seqnum(body[W_SEQ], self.__cnt_seqnum):
            logger.warning('Unexpected seqnum from container: %d (last seen: %d)', body[W_SEQ],
                           self.__cnt_seqnum)
        self.__cnt_seqnum = body[W_SEQ]

        # Check message hash
        if not self.__check_hash(body):
            logger.warning('Message has invalid hash, ignoring')
            return None

        # Decompress inner message
        try:
            msg = COMPRESSORS[body[W_COMPRESSION]].decompress(body[W_MESSAGE])
        except KeyError:
            logger.warning('Received message with unknown compression: %s', body[W_COMPRESSION])
            return None
        except OversizeException as ex:
            logger.warning('Uncompressed message exceeds %d bytes, ignoring', ex.size, exc_info=DEBUG_ENABLED)
            return None
        except:
            logger.warning('Decompression failed, ignoring message', exc_info=DEBUG_ENABLED)
            return None

        # Decode inner message
        try:
            msg = ubjloadb(msg, object_pairs_hook=OrderedDict)
        except:
            logger.warning('Failed to decode message, ignoring', exc_info=DEBUG_ENABLED)
            return None

        if self.__valid_msg_body(msg):
            return (msg, body[W_SEQ])
        else:
            logger.warning('Message with invalid body, ignoring: %s', msg)
            return None
17960
def decode(self, data, erase_pos=None, only_erasures=False):
        ''''''
        # erase_pos is a list of positions where you know (or greatly suspect at least) there is an erasure (ie, wrong character but you know it's at this position). Just input the list of all positions you know there are errors, and this method will automatically split the erasures positions to attach to the corresponding data chunk.
        if isinstance(data, str):
            data = bytearray(data, "latin-1")
        dec = bytearray()
        for i in xrange(0, len(data), self.nsize):
            # Split the long message in a chunk
            chunk = data[i:i+self.nsize]
            # Extract the erasures for this chunk
            e_pos = []
            if erase_pos:
                # First extract the erasures for this chunk (all erasures below the maximum chunk length)
                e_pos = [x for x in erase_pos if x <= self.nsize]
                # Then remove the extract erasures from the big list and also decrement all subsequent positions values by nsize (the current chunk's size) so as to prepare the correct alignment for the next iteration
                erase_pos = [x - (self.nsize+1) for x in erase_pos if x > self.nsize]
            # Decode/repair this chunk!
            dec.extend(rs_correct_msg(chunk, self.nsym, fcr=self.fcr, generator=self.generator, erase_pos=e_pos, only_erasures=only_erasures)[0])
        return dec
811876
def cookie_decode(data, key):
    ''' '''
    data = tob(data)
    if cookie_is_encoded(data):
        sig, msg = data.split(tob('?'), 1)
        if _lscmp(sig[1:], base64.b64encode(hmac.new(tob(key), msg).digest())):
            return pickle.loads(base64.b64decode(msg))
    return None
738811
def message_text(self, m_data):
        '''
        
        '''
        if m_data.get('type') != 'message':
            raise TypeError('This is not a message')
        # Edited messages have text in message
        _text = m_data.get('text', None) or m_data.get('message', {}).get('text', None)
        try:
            log.info('Message is %s', _text)  # this can violate the ascii codec
        except UnicodeEncodeError as uee:
            log.warning('Got a message that I could not log. The reason is: %s', uee)

        # Convert UTF to string
        _text = salt.utils.json.dumps(_text)
        _text = salt.utils.yaml.safe_load(_text)

        if not _text:
            raise ValueError('_text has no value')
        return _text
74690
def decode(mode=unicode_errors_default):
    """"""
    def dec(f):
        f._nvim_decode = mode
        return f
    return dec
1347904
def decode_response(client_message, to_object=None):
    
    parameters = dict(response=None)
    parameters['response'] = client_message.read_str()
    return parameters
129203
def _ensure_decoded(s):
    
    if isinstance(s, (np.bytes_, bytes)):
        s = s.decode(pd.get_option('display.encoding'))
    return s
659340
def _decode_received(self, msg):
        """"""
        if not isinstance(msg, six.binary_type):
            # already decoded - do nothing
            return msg
        # only decode from utf-8 if message is not binary data
        type = six.byte2int(msg[0:1])
        if type >= 48:  # no binary
            return msg.decode('utf-8')
        # binary message, don't try to decode
        return msg
629416
def decrypt(self, data, decode=False):
		

		#result = self.cipher().decrypt(data)
		result = self.cipher().decrypt_block(data)

		padding = self.mode().padding()
		if padding is not None:
			result = padding.reverse_pad(result, WAESMode.__data_padding_length__)

		return result.decode() if decode else result
53569
def safe_decode(s):
    """"""
    if isinstance(s, unicode):
        return s
    elif isinstance(s, bytes):
        return s.decode(defenc, 'surrogateescape')
    elif s is not None:
        raise TypeError('Expected bytes or text, but got %r' % (s,))
928410
def _decode_data(self, data):
        """"""
        self.major = data[0]

        if data[1] is 0xff:
            self.minor = data[1]
        elif data[1] <= 0x99:
            self.minor = int(data[1:2].tostring().decode('bcd+'))
        else:
            raise DecodingError()