code: 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
docs: Safely create a directory.
  
    Ensures a directory is present.  If it's not there, it is created.  If it
    is, it's a no-op. If clean is True, ensures the directory is empty.