Close file from its name
510509
def close_file_from_name(self, filename):
        """"""
        filename = osp.abspath(to_text_string(filename))
        index = self.editorstacks[0].has_filename(filename)
        if index is not None:
            self.editorstacks[0].close_file(index)
80460
def remove(name, path):
    '''
    
    '''
    cmd = [_get_cmd(), '--remove', name, path]
    out = __salt__['cmd.run_all'](cmd, python_shell=False)
    if out['retcode'] > 0:
        return out['stderr']
    return out['stdout']
934402
def getFilename(name):
    """"""
    # first replace all illegal chars
    name = re.sub(r"[^0-9a-zA-Z_\-\.]", "_", name)
    # then remove double dots and underscores
    while ".." in name:
        name = name.replace('..', '.')
    while "__" in name:
        name = name.replace('__', '_')
    # remove a leading dot or minus
    if name.startswith((".", "-")):
        name = name[1:]
    return name
311252
def close(self):
        """"""
        if self.filename != ':memory:':
            if self._conn is not None:
                self._conn.commit()
                self._conn.close()
                self._conn = None
78607
def close(self):
        """"""
        if not hasattr(self, 'tiffs'):
            return
        for tif in self._tiffs.values():
            if tif._fd:
                tif._fd.close()
                tif._fd = None
1233161
def cleanup(temp_name):
    '''  '''
    for filename in iglob(temp_name + '*' if temp_name else temp_name):
        try:
            os.remove(filename)
        except OSError:
            pass
497246
def safe_delete(filename):
  """"""
  try:
    os.unlink(filename)
  except OSError as e:
    if e.errno != errno.ENOENT:
      raise
668998
def _close_pidfile(self):
        """"""
        if self._pid_fd is not None:
            os.close(self._pid_fd)
        try:
            os.remove(self.pidfile)
        except OSError as ex:
            if ex.errno != errno.ENOENT:
                raise
654963
def cleanupFilename(self, name):
        """"""

        context = self.context
        id = ''
        name = name.replace('\\', '/')  # Fixup Windows filenames
        name = name.split('/')[-1]  # Throw away any path part.
        for c in name:
            if c.isalnum() or c in '._':
                id += c

        # Raise condition here, but not a lot we can do about that
        if context.check_id(id) is None and getattr(context, id, None) is None:
            return id

        # Now make the id unique
        count = 1
        while 1:
            if count == 1:
                sc = ''
            else:
                sc = str(count)
            newid = "copy{0:s}_of_{1:s}".format(sc, id)
            if context.check_id(newid) is None \
                    and getattr(context, newid, None) is None:
                return newid
            count += 1
988997
def askopenfilename(**kwargs):
    """"""
    try:
        from Tkinter import Tk
        import tkFileDialog as filedialog
    except ImportError:
        from tkinter import Tk, filedialog
    root = Tk()
    root.withdraw()
    root.update()
    filenames = filedialog.askopenfilename(**kwargs)
    root.destroy()
    return filenames
1280682
def close(self):
        
        if self._is_open:
            self.mode = None
            if self.handle:
                self.handle.close()
                self.handle = None
            self.filename = None
            self._is_open = False
            self.status = None
825999
private String cleanupFileName(String fileName) {
    String processedFileName = fileName;

    // strip off path parts
    if (StringUtils.contains(processedFileName, "/")) {
      processedFileName = StringUtils.substringAfterLast(processedFileName, "/");
    }
    if (StringUtils.contains(processedFileName, "\\")) {
      processedFileName = StringUtils.substringAfterLast(processedFileName, "\\");
    }

    // make sure filename does not contain any invalid characters
    processedFileName = Escape.validFilename(processedFileName);

    return processedFileName;
  }
1276650
def removed_tree(self, dirname):
        """"""
        dirname = osp.abspath(to_text_string(dirname))
        for fname in self.get_filenames():
            if osp.abspath(fname).startswith(dirname):
                self.close_file_from_name(fname)
944582
def remove_file(self, file_name, *args, **kwargs):
		
		previous_path = self.session_path()
		try:
			self.session_path(file_name)
			os.unlink(self.full_path())
		finally:
			self.session_path(previous_path)
1215624
def close(self):
    """"""
    self.acquire()
    try:
      self.flush()
      try:
        # Do not close the stream if it's sys.stderr|stdout. They may be
        # redirected or overridden to files, which should be managed by users
        # explicitly.
        if self.stream not in (sys.stderr, sys.stdout) and (
            not hasattr(self.stream, 'isatty') or not self.stream.isatty()):
          self.stream.close()
      except ValueError:
        # A ValueError is thrown if we try to run isatty() on a closed file.
        pass
      super(PythonHandler, self).close()
    finally:
      self.release()
850373
def kill(self):
        
        if os.path.isfile(self.filename):
            os.remove(self.filename)
        return
438656
def remove_file(path, remove=os.remove, exists=os.path.exists):
    """"""
    try:
        remove(path)
    except OSError:
        if exists(path):
            raise