def indent_docstr(s, indent, n=1, trim=True):
    "Add common indentation to all lines except first\n\n    Args:\n        s (str): docstring starting at indentation level 0\n        indent (str): text used for indentation, in practice\n            this will be the level of the declaration + 1\n        n (int): don't indent first n lines\n        trim (bool): trim whitespace (' \t') out of blank lines\n\n    Returns:\n        s with common indentation applied\n    "
    lines = s.splitlines(keepends=True)
    for i in range(n, len(lines)):
        if (lines[i].strip() or (not trim)):
            lines[i] = '{0}{1}'.format(indent, lines[i])
        else:
            lines[i] = lines[i].strip(' \t')
    return ''.join(lines)
Add common indentation to all lines except first

Args:
    s (str): docstring starting at indentation level 0
    indent (str): text used for indentation, in practice
        this will be the level of the declaration + 1
    n (int): don't indent first n lines
    trim (bool): trim whitespace ('         ') out of blank lines

Returns:
    s with common indentation applied
def indent_docstr(s, indent, n=1, trim=True):
    "Add common indentation to all lines except first\n\n    Args:\n        s (str): docstring starting at indentation level 0\n        indent (str): text used for indentation, in practice\n            this will be the level of the declaration + 1\n        n (int): don't indent first n lines\n        trim (bool): trim whitespace (' \t') out of blank lines\n\n    Returns:\n        s with common indentation applied\n    "
    lines = s.splitlines(keepends=True)
    for i in range(n, len(lines)):
        if (lines[i].strip() or (not trim)):
            lines[i] = '{0}{1}'.format(indent, lines[i])
        else:
            lines[i] = lines[i].strip(' \t')
    return .join(lines)