Splits the original lines list according to the current console width and group indentations.

        :param original_lines: The original lines list to split.
        :return: A list of the new width-formatted lines.
437984
def _split_lines(self, original_lines: List[str]) -> List[str]:
        
        console_width = get_console_width()
        # We take indent into account only in the inner group lines.
        max_line_length = console_width - len(self.LINE_SEP) - self._last_position - \
            (self.indents_sum if not self._is_first_line else self.indents_sum - self._indents[-1])

        lines = []
        for i, line in enumerate(original_lines):
            fixed_line = []
            colors_counter = 0
            line_index = 0
            while line_index < len(line):
                c = line[line_index]

                # Check if we're in a color block.
                if self._colors and c == self._ANSI_COLOR_PREFIX and \
                        len(line) >= (line_index + self._ANSI_COLOR_LENGTH):
                    current_color = line[line_index:line_index + self._ANSI_COLOR_LENGTH]
                    # If it really is a color, skip it.
                    if self._ANSI_REGEXP.match(current_color):
                        line_index += self._ANSI_COLOR_LENGTH
                        fixed_line.extend(list(current_color))
                        colors_counter += 1
                        continue
                fixed_line.append(line[line_index])
                line_index += 1

                # Create a new line, if max line is reached.
                if len(fixed_line) >= max_line_length + (colors_counter * self._ANSI_COLOR_LENGTH):
                    # Special case in which we want to split right before the line break.
                    if len(line) > line_index and line[line_index] == self.LINE_SEP:
                        continue
                    line_string = ''.join(fixed_line)
                    if not line_string.endswith(self.LINE_SEP):
                        line_string += self.LINE_SEP
                    lines.append(line_string)
                    fixed_line = []
                    colors_counter = 0
                    self._last_position = 0
                    # Max line length has changed since the last position is now 0.
                    max_line_length = console_width - len(self.LINE_SEP) - self.indents_sum
                    self._is_first_line = False

            if len(fixed_line) > 0:
                fixed_line = ''.join(fixed_line)
                # If this line contains only color codes, attach it to the last line instead of creating a new one.
                if len(fixed_line) == self._ANSI_COLOR_LENGTH and self._ANSI_REGEXP.match(fixed_line) is not None and \
                        len(lines) > 0:
                    lines[-1] = lines[-1][:-1] + fixed_line
                else:
                    lines.append(fixed_line)
        return lines
207646
def ruby_lines(text):
    
    if isinstance(text, basestring):
        text = text.splitlines()
    elif not isinstance(text, list):
        raise TypeError("text should be a list or a string, not %s"
                        % type(text))
    return [l.strip() for l in text if l.strip() and not
            l.strip().startswith('#')]
648459
def wrap_line(line, maxline=79, result=[], count=count):
    

    # Extract the indentation

    append = result.append
    extend = result.extend

    indentation = line[0]
    lenfirst = len(indentation)
    indent = lenfirst - len(indentation.lstrip())
    assert indent in (0, lenfirst)
    indentation = line.pop(0) if indent else ''

    # Get splittable/non-splittable groups

    dgroups = list(delimiter_groups(line))
    unsplittable = dgroups[::2]
    splittable = dgroups[1::2]

    # If the largest non-splittable group won't fit
    # on a line, try to add parentheses to the line.

    if max(count(x) for x in unsplittable) > maxline - indent:
        line = add_parens(line, maxline, indent)
        dgroups = list(delimiter_groups(line))
        unsplittable = dgroups[::2]
        splittable = dgroups[1::2]

    # Deal with the first (always unsplittable) group, and
    # then set up to deal with the remainder in pairs.

    first = unsplittable[0]
    append(indentation)
    extend(first)
    if not splittable:
        return result
    pos = indent + count(first)
    indentation += '    '
    indent += 4
    if indent >= maxline/2:
        maxline = maxline/2 + indent

    for sg, nsg in zip(splittable, unsplittable[1:]):

        if sg:
            # If we already have stuff on the line and even
            # the very first item won't fit, start a new line
            if pos > indent and pos + len(sg[0]) > maxline:
                append('\n')
                append(indentation)
                pos = indent

            # Dump lines out of the splittable group
            # until the entire thing fits
            csg = count(sg)
            while pos + csg > maxline:
                ready, sg = split_group(sg, pos, maxline)
                if ready[-1].endswith(' '):
                    ready[-1] = ready[-1][:-1]
                extend(ready)
                append('\n')
                append(indentation)
                pos = indent
                csg = count(sg)

            # Dump the remainder of the splittable group
            if sg:
                extend(sg)
                pos += csg

        # Dump the unsplittable group, optionally
        # preceded by a linefeed.
        cnsg = count(nsg)
        if pos > indent and pos + cnsg > maxline:
            append('\n')
            append(indentation)
            pos = indent
        extend(nsg)
        pos += cnsg
659849
def remove_initial_spaces_and_mark_message_lines(lines):
    
    i = 0
    while i < len(lines):
        lines[i] = lines[i].lstrip(' ')
        i += 1
    return mark_message_lines(lines)
1001644
def split_unquoted_newlines(stmt):
    """"""
    text = text_type(stmt)
    lines = SPLIT_REGEX.split(text)
    outputlines = ['']
    for line in lines:
        if not line:
            continue
        elif LINE_MATCH.match(line):
            outputlines.append('')
        else:
            outputlines[-1] += line
    return outputlines
186244
def _split_line(self, line_str):
        """"""
        arr = line_str.rstrip().split("\t")
        if len(arr) != self.expected_fields:
            raise exceptions.InvalidRecordException(
                (
                    "The line contains an invalid number of fields. Was "
                    "{} but expected {}\n{}".format(len(arr), 9 + len(self.samples.names), line_str)
                )
            )
        return arr
4765
def width_aware_splitlines(self, columns):
        # type: (int) -> Iterator[FmtStr]
        
        if columns < 2:
            raise ValueError("Column width %s is too narrow." % columns)
        if wcswidth(self.s) == -1:
            raise ValueError('bad values for width aware slicing')
        return self._width_aware_splitlines(columns)
893676
def fix_line_breaks(s):
    
    l = s.splitlines()
    x = [i.strip() for i in l]
    x = [i for i in x if i]  # remove blank lines
    return "\n".join(x)
271366
def line_width(line):
    
    if six.PY2:
        assert isinstance(line, unicode)
    _line = width_cal_preprocess(line)
    result = sum(map(get_char_width, _line))
    return result
1263637
def _newline_tokenize(self, data):
        
        parts = data.split('\n')
        tokens = []
        for num, part in enumerate(parts):
            if part:
                tokens.append((self.TOKEN_DATA, None, None, part))
            if num < (len(parts) - 1):
                tokens.append((self.TOKEN_NEWLINE, None, None, '\n'))
        return tokens
1218995
def split_leading_indent(line, max_indents=None):
    """"""
    indent = ""
    while (
        (max_indents is None or max_indents > 0)
        and line.startswith((openindent, closeindent))
    ) or line.lstrip() != line:
        if max_indents is not None and line.startswith((openindent, closeindent)):
            max_indents -= 1
        indent += line[0]
        line = line[1:]
    return indent, line
346349
def split_markers_from_line(line):
    # type: (AnyStr) -> Tuple[AnyStr, Optional[AnyStr]]
    """"""
    if not any(line.startswith(uri_prefix) for uri_prefix in SCHEME_LIST):
        marker_sep = ";"
    else:
        marker_sep = "; "
    markers = None
    if marker_sep in line:
        line, markers = line.split(marker_sep, 1)
        markers = markers.strip() if markers else None
    return line, markers
74491
def append(self, lines):
        
        if isinstance(lines, list):
            self._lines = self._lines + lines
        elif isinstance(lines, str):
            lines = lines.split('\n')
            self._lines = self._lines + lines
        else:
            raise TypeError('Unsupported type {0} for lines.'.format(type(lines)))
445823
def split_line(self, line):
        
        remainder = []
        while True:
            try:
                args = shlex.split(line)
            except ValueError:
                remainder.append(line[-1])
                line = line[:-1]
            else:
                if remainder:
                    args.append(''.join(reversed(remainder)))
                return args
1145061
def strip_units_from_lines(lines):
    
    for line in lines:
        for unit in ALL_UNITS:
            if line.endswith(" %s" % unit):
                line = line[:-1-len(unit)]
        yield line
182860
def parse_lines(self, lines):
        
        indent = ''
        level = 0

        if lines[0][0] == ' ' or lines[0][0] == '\t':
            raise CommandError("The first line in the file cannot start with a space or tab.")

        # This keeps track of the current parents at a given level
        current_parents = {0: None}

        for line in lines:
            if len(line) == 0:
                continue
            if line[0] == ' ' or line[0] == '\t':
                if indent == '':
                    indent = self.get_indent(line)
                elif not line[0] in indent:
                    raise CommandError("You can't mix spaces and tabs for indents")
                level = line.count(indent)
                current_parents[level] = self.make_category(line, parent=current_parents[level - 1])
            else:
                # We are back to a zero level, so reset the whole thing
                current_parents = {0: self.make_category(line)}
        current_parents[0]._tree_manager.rebuild()
149372
def splitlines(self, keepends=False):
        
        # Py2 unicode.splitlines() takes keepends as an optional parameter,
        # not as a keyword argument as in Python 3 str.
        parts = super(newstr, self).splitlines(keepends)
        return [newstr(part) for part in parts]