def format_block(block, nlspaces=0):
 import re
 lines = str(block).split('\n')
 while (lines and (not lines[0])):
  del lines[0]
 while (lines and (not lines[(-1)])):
  del lines[(-1)]
 ws = re.match('\\s*', lines[0]).group(0)
 if ws:
  lines = map((lambda x: x.replace(ws, '', 1)), lines)
 while (lines and (not lines[0])):
  del lines[0]
 while (lines and (not lines[(-1)])):
  del lines[(-1)]
 flines = [('%s%s' % ((' ' * nlspaces), line)) for line in lines]
 return ('\n'.join(flines) + '\n')

def format_block ( block , nlspaces = 0 ) : import re lines = str ( block ) . split ( '\n' ) while ( lines and ( not lines [ 0 ] ) ) : del lines [ 0 ] while ( lines and ( not lines [ ( - 1 ) ] ) ) : del lines [ ( - 1 ) ] ws = re . match ( '\\s*' , lines [ 0 ] ) . group ( 0 ) if ws : lines = map ( ( lambda x : x . replace ( ws , '' , 1 ) ) , lines ) while ( lines and ( not lines [ 0 ] ) ) : del lines [ 0 ] while ( lines and ( not lines [ ( - 1 ) ] ) ) : del lines [ ( - 1 ) ] flines = [ ( '%s%s' % ( ( ' ' * nlspaces ) , line ) ) for line in lines ] return ( '\n' . join ( flines ) + '\n' )
format the given block of text .