Split data into list of string, each (self.width() - 1) length or less. If nul-length string
		specified then empty list is returned

		:param data: data to split
		:return: list of str
439388
def split(self, data):
		
		line = deepcopy(data)
		line_width = (self.width() - 1)

		lines = []
		while len(line):

			new_line = line[:line_width]

			new_line_pos = new_line.find('\n')
			if new_line_pos >= 0:
				new_line = line[:new_line_pos]
				line = line[(new_line_pos + 1):]
			else:
				line = line[line_width:]

			lines.append(new_line)

		return lines
618221
def chunks(data, chunk_size):
    
    for i in xrange(0, len(data), chunk_size):
        yield data[i:i+chunk_size]
489756
def _pad(self, data):
        
        length = 16 - (len(data) % 16)
        data += chr(length)*length
        return data
141611
def _string_to_byte_list(self, data):
        
        bytes_length = 16

        m = self.digest()
        m.update(str.encode(data))
        hex_digest = m.hexdigest()

        return list(int(hex_digest[num * 2:num * 2 + 2], bytes_length)
                    for num in range(bytes_length))
1040474
def split_data(data, subset, splits):
  '''
  '''

  return dict([(k, data[k][splits[subset]]) for k in data])
790559
def unpack_data(data):
    
    # Note: This function cannot detect it when a user only returns 1
    # item that is exactly of length 2 (e.g. because the batch size is
    # 2). In that case, the item will be erroneously split into X and
    # y.
    try:
        X, y = data
        return X, y
    except ValueError:
        # if a 1-tuple/list or something else like a torch tensor
        if not isinstance(data, (tuple, list)) or len(data) < 2:
            raise ValueError(ERROR_MSG_1_ITEM)
        raise ValueError(ERROR_MSG_MORE_THAN_2_ITEMS.format(len(data)))
670682
def prepare(self, data):
        
        result = []

        for item in self.get_inner_data(data):
            result.append(self.preparer.prepare(item))

        return result
1303146
def split_into_segments(data):
    
    if data[0:2] != b"\xff\xd8":
        raise InvalidImageDataError("Given data isn't JPEG.")

    head = 2
    segments = [b"\xff\xd8"]
    while 1:
        if data[head: head + 2] == b"\xff\xda":
            segments.append(data[head:])
            break
        else:
            length = struct.unpack(">H", data[head + 2: head + 4])[0]
            endPoint = head + length + 2
            seg = data[head: endPoint]
            segments.append(seg)
            head = endPoint

        if (head >= len(data)):
            raise InvalidImageDataError("Wrong JPEG data.")
    return segments
866250
def data(self,data):
        """"""
        assert type(data) is np.ndarray
        assert data.shape[1] == self.nCols
        for i in range(self.nCols):
            self.colData[i]=data[:,i].tolist()
447354
def zero_width_split(pattern, string):
    
    splits = list((m.start(), m.end()) for m in regex.finditer(pattern, string, regex.VERBOSE))
    starts = [0] + [i[1] for i in splits]
    ends = [i[0] for i in splits] + [len(string)]
    return [string[start:end] for start, end in zip(starts, ends)]
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
187720
def fixed_length_split(s, width):
    
    # 使用正则的方法
    # import re
    # split = re.findall(r'.{%s}' % width, string)
    return [s[x: x + width] for x in range(0, len(s), width)]
108789
def parse_width(width, n):
    
    if isinstance(width, int):
        widths = [width] * n

    else:
        assert len(width) == n, "Widths and data do not match"
        widths = width

    return widths
489730
def data_item(data):
    
    if isinstance(data, ndict):
        # OK, we have something that looks like {0: ('a', 'b')}
        # or something that is a regular dictionary
        # so try to return 'a' regardless of the length
        for item in data:
            return repr(data[item][0])
    elif isinstance(data, dict):
        for item in data:
            return repr(data[item])
    elif isinstance(data, list):
        return repr(data[0])
    return repr(data)
1185163
def split_strings_in_list_retain_spaces(orig_list):
    
    temp_list = list()
    for line in orig_list:
        line_split = __re.split(r'(\s+)', line)
        temp_list.append(line_split)

    return temp_list
1231409
def chunked(data, chunksize):
    
    if chunksize < 1:
        raise ValueError("Chunksize must be at least 1!")
    if int(chunksize) != chunksize:
        raise ValueError("Chunksize needs to be an integer")
    res = []
    cur = []
    for e in data:
        cur.append(e)
        if len(cur) >= chunksize:
            res.append(cur)
            cur = []
    if cur:
        res.append(cur)
    return res
1280562
async def _string_data(self, data):
        
        reply = ''
        data = data[1:-1]
        for x in data:
            reply_data = x
            if reply_data:
                reply += chr(reply_data)
        if self.log_output:
            logging.info(reply)
        else:
            print(reply)