Delete a file safely. If it's not present, no-op.
497246
def safe_delete(filename):
  """"""
  try:
    os.unlink(filename)
  except OSError as e:
    if e.errno != errno.ENOENT:
      raise
106020
def remove(in_bam):
    
    if utils.file_exists(in_bam):
        utils.remove_safe(in_bam)
    if utils.file_exists(in_bam + ".bai"):
        utils.remove_safe(in_bam + ".bai")
1033828
def _remove(self, n):
        
        if os.path.isfile(n):
            os.remove(n)
        if not os.path.isfile(n):
            print("File '{0}' removed".format(n))
538495
def delete(filename)
      resp = sendcmd("DELE " + filename)
      if resp[0, 3] == "250"
        return
      elsif resp[0] == ?5
        raise FTPPermError, resp
      else
        raise FTPReplyError, resp
      end
    end
1087430
def delete(filething):
    

    t = OggSpeex(filething)
    filething.fileobj.seek(0)
    t.delete(filething)
778760
def delete(self):
        """"""
        self._ensure_filename()
        self._close_if_open()
        os.remove(self.filename)
102486
def remove_file(self, file_name, *args, **kwargs):
		
		client = self.dav_client()
		remote_path = self.join_path(self.session_path(), file_name)
		if client.is_dir(remote_path) is True:
			raise ValueError('Unable to remove non-file entry')
		client.clean(remote_path)
1025639
def validate_remove_file(remove_file):
    
    if not os.path.isfile(remove_file):
        logger.warn("WARN: Remove file does not exist")
        return False
    # Make sure permissions are 600
    mode = stat.S_IMODE(os.stat(remove_file).st_mode)
    if not mode == 0o600:
        logger.error("ERROR: Invalid remove file permissions"
                     "Expected 0600 got %s" % oct(mode))
        return False
    else:
        logger.debug("Correct file permissions")

    if os.path.isfile(remove_file):
        parsedconfig = RawConfigParser()
        parsedconfig.read(remove_file)
        rm_conf = {}
        for item, value in parsedconfig.items('remove'):
            rm_conf[item] = value.strip().split(',')
        # Using print here as this could contain sensitive information
        logger.debug("Remove file parsed contents")
        logger.debug(rm_conf)
    logger.info("JSON parsed correctly")
    return True
998223
def delete(filething):
    

    f = FLAC(filething)
    filething.fileobj.seek(0)
    f.delete(filething)
601447
def remove_file(self, path):
        """"""
        self.get_file(path).remove()
        self.remove_cache_buster(path)
1684
def delete(self):
        """"""
        if self.isfile:
            os.remove(self.fn)
        elif self.isdir:
            shutil.rmtree(self.fn)
930312
def _write_file_safely(local_path, fileinfo, response):
    """"""
    try:
        _write_file(local_path, fileinfo, response)
    except BaseException as e:
        logger.warning("{} interrupted writing {} -- "
                       "cleaning up partial file".format(
                       e.__class__.__name__, local_path))
        os.remove(local_path)
        raise e
545549
def rm_file_or_dir(path, ignore_errors=True):
    
    if os.path.exists(path):
        if os.path.isdir(path):
            if os.path.islink(path):
                os.unlink(path)
            else:
                shutil.rmtree(path, ignore_errors=ignore_errors)
        else:
            if os.path.islink(path):
                os.unlink(path)
            else:
                os.remove(path)
1325577
def reset_files(self):
        
        confirm = self.no_confirm

        path = SavepathParser.get_base_path(
            SavepathParser.get_abs_path_static(
                self.cfg.section("Files")["local_data_directory"],
                os.path.dirname(self.cfg_file_path)
            )
        )

        print("""
Cleanup files:
    This will delete {path} and all its contents.
""".format(path=path))

        if not confirm:
            confirm = 'yes' in builtins.input(
                """
    Do you really want to do this? Write 'yes' to confirm: {yes}"""
                    .format(yes='yes' if confirm else ''))

        if not confirm:
            print("Did not type yes. Thus aborting.")
            return

        print("Removing: {}".format(path))

        try:
            shutil.rmtree(path)
        except OSError as error:
            if not os.path.exists(path):
                self.log.error("%s does not exist.", path)
            self.log.error(error)
815817
def remove_file(self, name):
        """"""
        self.check_write(name)
        path = os.path.join(self.cur_dir, name)
        os.remove(path)
319259
def drop(self):
        
        import os

        if self.path:
            if os.path.exists(self.path):
                os.remove(self.path)
        else:
            # Clear the in-memory data if there is no file path
            self._data = {}
438656
def remove_file(path, remove=os.remove, exists=os.path.exists):
    """"""
    try:
        remove(path)
    except OSError:
        if exists(path):
            raise