Small convenience function that creates temporary files.

    This function is a wrapper around the Python built-in
    function tempfile.mkstemp.
553755
def create_temp_file_name(suffix, prefix=None, dir=None, directory=None):
    
    if dir is not None:
        warnings.warn(
            "The dir argument is deprecated.\n" +
            "Please use the directory argument instead.", DeprecationWarning)
        # Deprecated since 1.9.0, will be removed in 2.0.0
        directory = dir

    if not prefix:
        prefix = tempfile.gettempprefix()
    fd, name = tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=directory)
    file_obj = os.fdopen(fd)
    file_obj.close()
    return name
1130579
static synchronized File tempFile(HttpServerFileUpload upload) {
        String newpostfix;
        String diskFilename = new File(upload.filename()).getName();
        newpostfix = '_' + diskFilename;
        File tmpFile;
        try {
            if (baseDirectory == null) {
                // create a temporary file
                tmpFile = File.createTempFile(prefix, newpostfix);
            } else {
                tmpFile = File.createTempFile(prefix, newpostfix, new File(
                        baseDirectory));
            }
            if (deleteOnExitTemporaryFile) {
                tmpFile.deleteOnExit();
            }
            return tmpFile;
        } catch (IOException e) {
            // Really bad, can't create the tmp file.
            throw new IllegalStateException(e);
        }

    }
625204
def temp_output_file(prefix="tmp", suffix="", dir=None, make_parents=False, always_clean=False):
  
  return _temp_output(False, prefix=prefix, suffix=suffix, dir=dir, make_parents=make_parents,
                      always_clean=always_clean)
343587
private static File createTempFile(File baseFile) {
        File parentDirectory = baseFile.getParentFile();
        String filename = baseFile.getName();
        return new File(parentDirectory, '_' + filename);
    }
278201
private static File createTempFile() throws IOException
  {
    File file = File.createTempFile(TMP_FILE_PREFIX, TMP_FILE_EXTENSION);
    file.deleteOnExit();
    return file;
  }
1353157
def create_files(filedef, cleanup=True):
    
    cwd = os.getcwd()
    tmpdir = tempfile.mkdtemp()
    try:
        Filemaker(tmpdir, filedef)
        if not cleanup:  # pragma: nocover
            pass
            # print("TMPDIR =", tmpdir)
        os.chdir(tmpdir)
        yield tmpdir
    finally:
        os.chdir(cwd)
        if cleanup:  # pragma: nocover
            shutil.rmtree(tmpdir, ignore_errors=True)
1224064
def atomic_create_file(file_path):
    """"""
    fd, tmp_file_path = tempfile.mkstemp(
        prefix=os.path.basename(file_path), dir=os.path.dirname(file_path), suffix=".metadata_tmp"
    )
    try:
        with os.fdopen(fd, "w") as out_file:
            yield out_file

        os.rename(tmp_file_path, file_path)
    except Exception:  # pytest: disable=broad-except
        with contextlib.suppress(Exception):
            os.unlink(tmp_file_path)
        raise
497706
def makeTempFile(self):
        

        if self.strategy == 0:
            try:
                new_delegate = self.STRATEGIES[1]()
                new_delegate.write(self.getvalue())
                self._delegate = new_delegate
                self.strategy = 1
                log.warn("Created temporary file %s", self.name)
            except:
                self.capacity = - 1
339551
def _make_temp_directory(prefix):
    '''
    
    '''
    temp_dir = _make_temp_filename(prefix=str(prefix))
    _os.makedirs(temp_dir)
    return temp_dir
398772
public static Resource temporaryFile(String name, String extension) throws IOException {
      return new FileResource(File.createTempFile(name, extension));
   }
758489
public static File createTempDir() throws IllegalStateException
   {
      File baseDir = getTempDirectory();
      try
      {
         return Files.createTempDirectory(baseDir.toPath(), "tmpdir").toFile();
      }
      catch (IOException e)
      {
         throw new IllegalStateException("Error while creating temporary directory", e);
      }
   }
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))
45189
def _create_tmp_file(config):
        """"""
        tmp_dir = tempfile.gettempdir()
        rand_fname = py23_compat.text_type(uuid.uuid4())
        filename = os.path.join(tmp_dir, rand_fname)
        with open(filename, 'wt') as fobj:
            fobj.write(config)
        return filename
1301998
def temp_directory(*args, **kwargs):
    

    path = tempfile.mkdtemp(*args, **kwargs)
    try:
        yield path
    finally:
        shutil.rmtree(path)
1237702
def tmpfile (dir=None, prefix="temp", suffix=None):
    """"""
    return tempfile.mkstemp(suffix=suffix, prefix=prefix, dir=dir)[1]
257003
public PathImpl createTempFile(String prefix, String suffix) throws IOException
  {
    if (prefix == null || prefix.length () == 0)
      prefix = "t";

    if (suffix == null)
      suffix = ".tmp";

    synchronized (LOCK) {
      for (int i = 0; i < 32768; i++) {
        int r = Math.abs((int) RandomUtil.getRandomLong());
        PathImpl file = lookup(prefix + r + suffix);

        if (file.createNewFile())
          return file;
      }
    }

    throw new IOException("cannot create temp file");
  }
1189872
def _open_tmpfile(self, **kwargs):
        
        self.tmpfile = get_tempfile(**kwargs)
        path = self.tmpfile.name
        return path