def safe_mkdir(directory, clean=False):
 if clean:
  safe_rmtree(directory)
 try:
  os.makedirs(directory)
 except OSError as e:
  if (e.errno != errno.EEXIST):
   raise

def safe_mkdir ( directory , clean = False ) : if clean : safe_rmtree ( directory ) try : os . makedirs ( directory ) except OSError as e : if ( e . errno != errno . EEXIST ) : raise
ensure a directory is present .