def _ensure_dir(directory):
 try:
  os.makedirs(directory)
 except OSError as exc:
  if (exc.errno == errno.EEXIST):
   pass
  else:
   raise

def _ensure_dir ( directory ) : try : os . makedirs ( directory ) except OSError as exc : if ( exc . errno == errno . EEXIST ) : pass else : raise
ensure that directory exists .