

def _trim(docstring, return_lines=False):
    '\n    Trim of unnecessary leading indentations.\n    '
    if (not docstring):
        return ''
    lines = docstring.expandtabs().splitlines()
    indent = _min_indent(lines)
    trimmed = [lines[0].strip()]
    if (indent < _maxsize):
        for line in lines[1:]:
            trimmed.append(line[indent:].rstrip())
    while (trimmed and (not trimmed[(- 1)])):
        trimmed.pop()
    while (trimmed and (not trimmed[0])):
        trimmed.pop(0)
    if return_lines:
        return trimmed
    else:
        return '\n'.join(trimmed)

dataset/ETHPy150Open Calysto/metakernel/metakernel/magic.py _trim/original