Join one or multiple lines that wrapped. Returns the reconstructed line.
    Takes into account proper spacing between the lines (see
    STRIP_SPACE_CHARS).
492788
def join_wrapped_lines(lines):
    
    if len(lines) == 1:
        return lines[0]

    joined = lines[0]
    for line in lines[1:]:
        if joined and joined[-1] in STRIP_SPACE_CHARS:
            joined += line
        else:
            joined += ' '
            joined += line

    return joined
1195003
def strip_line(line, sep=os.linesep):
    

    try:
        return line.strip(sep)
    except TypeError:
        return line.decode('utf-8').strip(sep)
917921
def csv_line(self, line):
        ''''''
        self.csv_sep = ","
        return self.csv_sep.join(['"' + str(x) + '"' for x in line])
1204073
def textForSaving(self):
        
        lines = self.text.splitlines()
        if self.text.endswith('\n'):  # splitlines ignores last \n
            lines.append('')
        return self.eol.join(lines) + self.eol
534845
private List<String> wrapLines(String line, final int maxLength) {
    	List<String> rv = new ArrayList<String>();
        for (String restOfLine : line.split("\\n")) {
            while (restOfLine.length() > maxLength) {
                // try to wrap at space, but don't try too hard as some languages don't even have whitespaces.
                int lineLength;
                String candidate = restOfLine.substring(0, maxLength);
                int sp=candidate.lastIndexOf(' ');
                if(sp>maxLength*3/5)    lineLength=sp;
                else                    lineLength=maxLength;
                rv.add(restOfLine.substring(0, lineLength));
                restOfLine = restOfLine.substring(lineLength).trim();
            }
            rv.add(restOfLine);
        }
    	return rv;
    }
341921
function combineMultiLines(lines) {
    return lines.reduce((acc, cur) => {
        const line = acc[acc.length - 1];
        if (acc.length && isLineContinued(line)) {
            acc[acc.length - 1] = line.replace(/\\$/, '');
            acc[acc.length - 1] += cur;
        } else {
            acc.push(cur);
        }
        return acc;
    }, []);
}
959997
def wrap(width: 78, indent: 0, indent_after: false, segments: false)
    if segments
      text = Text.wrap_segments(@lines[@line], width: width, indent: indent, indent_after: indent_after)
    else
      text = Text.wrap(@lines[@line], width: width, indent: indent, indent_after: indent_after)
    end
    @lines.delete_at(@line)
    @line -= 1
    text.split("\n").each {|line| self.next(line) }
    return self
  end
1261601
def wrap_text(text, width):
        
        out = []
        for paragraph in text.splitlines():
            # Wrap returns an empty list when paragraph is a newline. In order
            # to preserve newlines we substitute a list containing an empty
            # string.
            lines = wrap(paragraph, width=width) or ['']
            out.extend(lines)
        return out
748434
def join(strings: Optional[Sequence[str]], separator: str = "") -> str:
    
    return separator.join(s for s in strings if s) if strings else ""
1094754
def _indent_line(self, line, stripspace=''):
        """"""

        return re.sub(r"^%s" % stripspace, self.indentstring
                      * self.indent, line)
1236671
def rewrap(s, width=COLS):
    
    s = ' '.join([l.strip() for l in s.strip().split('\n')])
    return '\n'.join(textwrap.wrap(s, width))
1176201
def join_logical_line(logical_line):
    """"""
    indentation = _get_indentation(logical_line)

    return indentation + untokenize_without_newlines(
        generate_tokens(logical_line.lstrip())) + '\n'
661800
def word_wrap(text, columns=80, indent=4, padding=2):
    
    paragraphs = _PARA_BREAK.split(text)
    lines = []
    columns -= padding
    for para in paragraphs:
        if para.isspace():
            continue
        line = ' ' * indent
        for word in para.split():
            if (len(line) + 1 + len(word)) > columns:
                lines.append(line)
                line = ' ' * padding
                line += word
            else:
                line += ' ' + word
        if not line.isspace():
            lines.append(line)
    return lines
1001928
def unfold_lines(string):
    '''
    '''
    assert isinstance(string, str), 'Expect str. Got {}'.format(type(string))
    lines = string.splitlines()
    line_buffer = io.StringIO()

    for line_number in range(len(lines)):
        line = lines[line_number]
        if line and line[0:1] in (' ', '\t'):
            line_buffer.write(' ')
        elif line_number != 0:
            line_buffer.write('\r\n')
        line_buffer.write(line.strip())

    line_buffer.write('\r\n')

    return line_buffer.getvalue()
1314590
def _combine_lines(self, lines):
        
        lines = filter(None, map(lambda x: x.strip(), lines))
        return '[' + ','.join(lines) + ']'
1134890
public static String combineLines( String[] lines,
                                       char separator ) {
        if (lines == null || lines.length == 0) return "";
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i != lines.length; ++i) {
            String line = lines[i];
            if (i != 0) sb.append(separator);
            sb.append(line);
        }
        return sb.toString();
    }
17023
def _hjoin_multiline(join_char, strings):
    
    cstrings = [string.split("\n") for string in strings]
    max_num_lines = max(len(item) for item in cstrings)
    pp = []
    for k in range(max_num_lines):
        p = [cstring[k] for cstring in cstrings]
        pp.append(join_char + join_char.join(p) + join_char)

    return "\n".join([p.rstrip() for p in pp])