def indent(instr, nspaces=4, ntabs=0, flatten=False):
 if (instr is None):
  return
 ind = ((' DCTB ' * ntabs) + (' ' * nspaces))
 if flatten:
  pat = re.compile('^\\s*', re.MULTILINE)
 else:
  pat = re.compile('^', re.MULTILINE)
 outstr = re.sub(pat, ind, instr)
 if outstr.endswith((os.linesep + ind)):
  return outstr[:(- len(ind))]
 else:
  return outstr

def indent ( instr , nspaces = 4 , ntabs = 0 , flatten = False ) : if ( instr is None ) : return ind = ( ( ' DCTB ' * ntabs ) + ( ' ' * nspaces ) ) if flatten : pat = re . compile ( '^\\s*' , re . MULTILINE ) else : pat = re . compile ( '^' , re . MULTILINE ) outstr = re . sub ( pat , ind , instr ) if outstr . endswith ( ( os . linesep + ind ) ) : return outstr [ : ( - len ( ind ) ) ] else : return outstr
indent text .