def _reindent(s, indent, reformat=True):
 s = textwrap.dedent(s)
 s = s.split('\n')
 s = [x.rstrip() for x in s]
 while (s and (not s[0])):
  s = s[1:]
 while (s and (not s[(-1)])):
  s = s[:(-1)]
 if reformat:
  s = '\n'.join(s)
  s = textwrap.wrap(s, initial_indent=indent, subsequent_indent=indent)
 else:
  s = [(indent + x) for x in s]
 return ('\n'.join(s) + '\n')

def _reindent ( s , indent , reformat = True ) : s = textwrap . dedent ( s ) s = s . split ( '\n' ) s = [ x . rstrip ( ) for x in s ] while ( s and ( not s [ 0 ] ) ) : s = s [ 1 : ] while ( s and ( not s [ ( - 1 ) ] ) ) : s = s [ : ( - 1 ) ] if reformat : s = '\n' . join ( s ) s = textwrap . wrap ( s , initial_indent = indent , subsequent_indent = indent ) else : s = [ ( indent + x ) for x in s ] return ( '\n' . join ( s ) + '\n' )
remove the existing indentation from each line of a chunk of text .