def rm_rf(name):
 if (not os.path.exists(name)):
  return
 try:
  shutil.rmtree(name)
 except OSError as e:
  if (e.errno == errno.ENOTDIR):
   safe_delete(name)
  elif (e.errno != errno.ENOENT):
   raise

def rm_rf ( name ) : if ( not os . path . exists ( name ) ) : return try : shutil . rmtree ( name ) except OSError as e : if ( e . errno == errno . ENOTDIR ) : safe_delete ( name ) elif ( e . errno != errno . ENOENT ) : raise
platform-independent recursive delete .