Creates a temporary file, and returns its name.

    :param keep: If False (default), the directory will be recursively
                 deleted when Scapy exits.
    :return: A full path to a temporary directory.
337545
def get_temp_dir(keep=False):
    

    dname = tempfile.mkdtemp(prefix="scapy")

    if not keep:
        conf.temp_files.append(dname)

    return dname
1237702
def tmpfile (dir=None, prefix="temp", suffix=None):
    """"""
    return tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=dir)[1]
371712
def temporary_directory():
    
    dir_name = tempfile.mkdtemp()
    yield dir_name
    if os.path.exists(dir_name):
        shutil.rmtree(dir_name)
471844
def createTempFile(self, suffix=None, prefix=None, secure=True) -> 'File':
        
        if not secure:
            raise NotImplementedError("We only support secure files at this point")

        # tempfile.mkstemp(suffix=None, prefix=None, dir=None, text=False)

        newFileNum, newFileRealPath = tempfile.mkstemp(
            suffix=suffix, prefix=prefix, dir=self._path)
        os.close(newFileNum)

        relativePath = os.path.relpath(newFileRealPath, self.path)

        file = File(self, pathName=relativePath, exists=True)
        self._files[file.pathName] = file
        return file
798348
def create_tmp_rootdir(self):
        
        if self.rootdir:
            tmp_rootdir = tempfile.mkdtemp(prefix='bcolz-')
            self._dir_clean_list.append(tmp_rootdir)
        else:
            tmp_rootdir = None
        return tmp_rootdir
1166844
def temp_filename(self):
        
        # TODO: it would be nice to get this to behave more like a
        # context so we can make sure these temporary files are
        # removed, regardless of whether an error occurs or the
        # program is terminated.
        handle, filename = tempfile.mkstemp()
        os.close(handle)
        return filename
18611
def save_file(fullpath, entry):
    
    with tempfile.NamedTemporaryFile('w', delete=False) as file:
        tmpfile = file.name
        # we can't just use file.write(str(entry)) because otherwise the
        # headers "helpfully" do MIME encoding normalization.
        # str(val) is necessary to get around email.header's encoding
        # shenanigans
        for key, val in entry.items():
            print('{}: {}'.format(key, str(val)), file=file)
        print('', file=file)
        file.write(entry.get_payload())
    shutil.move(tmpfile, fullpath)
1126140
def _maketemp(name, createmode=None):
    
    d, fn = os.path.split(name)
    fd, tempname = tempfile.mkstemp(prefix=".%s-" % fn, dir=d)
    os.close(fd)

    # Temporary files are created with mode 0600, which is usually not
    # what we want. If the original file already exists, just copy its mode.
    # Otherwise, manually obey umask.
    try:
        st_mode = os.lstat(name).st_mode & 0o777
    except OSError as err:
        if err.errno != errno.ENOENT:
            raise
        st_mode = createmode
        if st_mode is None:
            st_mode = ~umask
        st_mode &= 0o666
    os.chmod(tempname, st_mode)

    return tempname
120100
def temporary_dir():
    
    d = tempfile.mkdtemp()
    try:
        with cd(d):
            yield d
    finally:
        if os.path.exists(d):
            shutil.rmtree(d)
317746
def fobj_to_tempfile(f, suffix=''):
    
    with tempfile.NamedTemporaryFile(
            dir=TEMPDIR, suffix=suffix, delete=False) as t:
        shutil.copyfileobj(f, t)
    try:
        yield t.name
    finally:
        os.remove(t.name)
21950
def path(self, **kwargs):
        
        new_path = path(self.getPath(), **kwargs)
        return File(new_path)
1175262
def _default_temporary_directory(self, prefix):
    """"""
    try:
      self.temporary_file = tempfile.NamedTemporaryFile(prefix=prefix)

    except OSError as err: # pragma: no cover
      logger.critical('Cannot create a system temporary directory: '+repr(err))
      raise securesystemslib.exceptions.Error(err)
726206
def make_directory(self, directory_name, *args, **kwargs):
		
		previous_path = self.session_path()
		try:
			self.session_path(directory_name)
			os.mkdir(self.full_path())
		finally:
			self.session_path(previous_path)
753324
def _gen_keep_files(name, require, walk_d=None):
    '''
    
    '''
    def _is_child(path, directory):
        '''
        Check whether ``path`` is child of ``directory``
        '''
        path = os.path.abspath(path)
        directory = os.path.abspath(directory)

        relative = os.path.relpath(path, directory)

        return not relative.startswith(os.pardir)

    def _add_current_path(path):
        _ret = set()
        if os.path.isdir(path):
            dirs, files = walk_d.get(path, ((), ()))
            _ret.add(path)
            for _name in files:
                _ret.add(os.path.join(path, _name))
            for _name in dirs:
                _ret.add(os.path.join(path, _name))
        return _ret

    def _process_by_walk_d(name, ret):
        if os.path.isdir(name):
            walk_ret.update(_add_current_path(name))
            dirs, _ = walk_d.get(name, ((), ()))
            for _d in dirs:
                p = os.path.join(name, _d)
                walk_ret.update(_add_current_path(p))
                _process_by_walk_d(p, ret)

    def _process(name):
        ret = set()
        if os.path.isdir(name):
            for root, dirs, files in salt.utils.path.os_walk(name):
                ret.add(name)
                for name in files:
                    ret.add(os.path.join(root, name))
                for name in dirs:
                    ret.add(os.path.join(root, name))
        return ret

    keep = set()
    if isinstance(require, list):
        required_files = [comp for comp in require if 'file' in comp]
        for comp in required_files:
            for low in __lowstate__:
                # A requirement should match either the ID and the name of
                # another state.
                if low['name'] == comp['file'] or low['__id__'] == comp['file']:
                    fn = low['name']
                    fun = low['fun']
                    if os.path.isdir(fn):
                        if _is_child(fn, name):
                            if fun == 'recurse':
                                fkeep = _gen_recurse_managed_files(**low)[3]
                                log.debug('Keep from %s: %s', fn, fkeep)
                                keep.update(fkeep)
                            elif walk_d:
                                walk_ret = set()
                                _process_by_walk_d(fn, walk_ret)
                                keep.update(walk_ret)
                            else:
                                keep.update(_process(fn))
                    else:
                        keep.add(fn)
    log.debug('Files to keep from required states: %s', list(keep))
    return list(keep)
1251519
def keep(self, diff):
        
        path = self.extraKeys[diff]

        if not path.startswith("/"):
            logger.debug("Keeping %s", path)
            del self.extraKeys[diff]
            return

        # Copy into self.userPath, if not there already

        keyName = self._keyName(diff.toUUID, diff.fromUUID, path)
        newPath = os.path.join(self.userPath, os.path.basename(path))
        newName = self._keyName(diff.toUUID, diff.fromUUID, newPath)

        if not self._skipDryRun(logger)("Copy %s to %s", keyName, newName):
            self.bucket.copy_key(newName, self.bucket.name, keyName)
342037
def mktemp_file(self):
        
        if not(os.path.exists(self.__dirname)):
            logging.debug("Creating directory {}".format(self.__dirname))
            os.mkdir(self.__dirname)
        elif not(os.path.isdir(self.__dirname)):
            raise TempDirIsFileException(
                "There is a file called %s in this directory!!!" %
                self.__dirname)
        #self.fdesc, self.fname = tempfile.mkstemp(dir=self.__dirname, text=True)
        self.f = tempfile.NamedTemporaryFile(dir=self.__dirname, delete=False, mode="wt")
        logging.debug("Creating file {}".format(self.f.name))
978670
def create_tempdir(suffix='', prefix='tmp', directory=None, delete=True):
    
    tempd = tempfile.mkdtemp(suffix=suffix, prefix=prefix, dir=directory)
    if delete:
        atexit.register(_cleanup_tempdir, tempd)
    return tempd