cli_helpers/utils.py
def bytes_to_string(b):
    """Convert bytes *b* to a string.

    Hexlify bytes that can't be decoded.

    """
    if isinstance(b, binary_type):
        try:
            return b.decode('utf8')
        except UnicodeDecodeError:
            return '0x' + binascii.hexlify(b).decode('ascii')
    return b
def bytes_to_string(b):
    """Convert bytes *b* to a string.

    Hexlify bytes that can't be decoded.

    """
    if isinstance(b, binary_type):
        try:
            return b.decode('utf8')
        except UnicodeDecodeError:
            return '0x' + binascii.hexlify(b).decode('ascii')
    return b
def bytes_to_string ( b ) : if isinstance ( b , binary_type ) : try : return b . decode ( 'utf8' ) except UnicodeDecodeError : return '0x' + binascii . hexlify ( b ) . decode ( 'ascii' ) return b
Convert bytes *b* to a string.

    Hexlify bytes that can't be decoded.
Convert bytes * b * to a string .