@staticmethod
def explode_by_spaces(x):
    """
        Разбивает массив байтов по пробелам,
        игнорируя те пробелы, перед которыми стоит слэш,
        но только если это не двойной слеш
        """
    if isinstance(x, bytearray) or isinstance(x, bytes):
        arr = x
        need_decode = False
    elif isinstance(x, str):
        arr = x.encode('UTF-8')
        need_decode = True
    parts = []
    cur_part = bytearray()
    prev_slash = False
    slash_byte = b'\\'[0]
    state = 0
    l = len(arr)
    for i in range(l):
        if arr[i] == slash_byte:
            if prev_slash:
                cur_part.append(slash_byte)
                prev_slash = False
            else:
                prev_slash = True
        elif arr[i] == 32:
            if prev_slash:
                cur_part.append(32)
                prev_slash = False
            elif len(cur_part) > 0:
                if not need_decode:
                    parts.append(bytes(cur_part))
                else:
                    parts.append(cur_part.decode('UTF-8'))
                cur_part = bytearray()
        elif prev_slash:
            cur_part.append([slash_byte, arr[i]])
        else:
            cur_part.append(arr[i])
    if len(cur_part):
        if not need_decode:
            parts.append(bytes(cur_part))
        else:
            parts.append(cur_part.decode('UTF-8'))
    return parts
