code: def replace_file_or_dir(dest, source):
      
      from rez.vendor.atomicwrites import replace_atomic
  
      if not os.path.exists(dest):
          try:
              os.rename(source, dest)
              return
          except:
              if not os.path.exists(dest):
                  raise
  
      try:
          replace_atomic(source, dest)
          return
      except:
          pass
  
      with make_tmp_name(dest) as tmp_dest:
          os.rename(dest, tmp_dest)
          os.rename(source, dest)
docs: Replace `dest` with `source`.
  
      Acts like an `os.rename` if `dest` does not exist. Otherwise, `dest` is
      deleted and `src` is renamed to `dest`.