#NEWLINE# def trim_docstring( docstring ) : #NEWLINE# #INDENT# '\n    Uniformly trims leading/trailing whitespace from docstrings.\n\n    Based on http://www.python.org/peps/pep-0257.html#handling-docstring-indentation\n    ' #NEWLINE# if ( ( not docstring ) or ( not docstring . strip ( ) ) ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# lines = docstring . expandtabs ( ) . splitlines ( ) #NEWLINE# indent = min ( [ ( len ( line ) - len ( line . lstrip ( ) ) ) for line in lines if line . lstrip ( ) ] ) #NEWLINE# trimmed = ( [ lines [ 0 ] . lstrip ( ) ] + [ line [ indent : ] . rstrip ( ) for line in lines [ 1 : ] ] ) #NEWLINE# return '\n' . join ( trimmed ) . strip ( )