Create a temporary file containing the program code. The code is
        fetched via :meth:`_get_program`.
164287
def _setup_program(self):
        
        filename = self._get_program_filename()
        path = os.path.join(self.get_temp_dir(), filename)
        self.program_fp = open(path, 'wb')
        self.program_fp.write(self._get_program())
        self.program_fp.flush()
        os.chmod(self.program_fp.name, int('0700', 8))
        reopen_readonly(self.program_fp)
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
407174
def temp_file():
    
    fd, path = tempfile.mkstemp()
    os.close(fd)
    try:
        yield path
    finally:
        os.remove(path)
825918
def create_copy(self):
        
        if self.executable is None or not isfile(self.executable):
            raise FileNotFoundError(
                "Could not find MAGICC{} executable: {}".format(
                    self.version, self.executable
                )
            )
        if self.is_temp:
            assert (
                self.root_dir is None
            ), "A temp copy for this instance has already been created"
            self.root_dir = mkdtemp(prefix="pymagicc-")

        if exists(self.run_dir):
            raise Exception("A copy of MAGICC has already been created.")
        if not exists(self.root_dir):
            makedirs(self.root_dir)

        exec_dir = basename(self.original_dir)

        # Copy a subset of folders from the MAGICC `original_dir`
        # Also copy anything which is in the root of the MAGICC distribution
        # Assumes that the MAGICC binary is in a folder one level below the root
        # of the MAGICC distribution. i.e. /run/magicc.exe or /bin/magicc
        dirs_to_copy = [".", "bin", "run"]
        # Check that the executable is in a valid sub directory
        assert exec_dir in dirs_to_copy, "binary must be in bin/ or run/ directory"

        for d in dirs_to_copy:
            source_dir = abspath(join(self.original_dir, "..", d))
            if exists(source_dir):
                _copy_files(source_dir, join(self.root_dir, d))

        # Create an empty out dir
        # MAGICC assumes that the 'out' directory already exists
        makedirs(join(self.root_dir, "out"))

        # Create basic configuration files so magicc can run
        self.set_years()
        self.set_config()
305650
def _copy_body_to_tempfile(cls, environ):
        
        try:
            length = int(environ.get('CONTENT_LENGTH', 0))
        except ValueError:
            length = 0

        try:
            fileobj = tempfile.SpooledTemporaryFile(1024*1024)
        except AttributeError:  # pragma: nocover
            fileobj = tempfile.TemporaryFile()  # py25 fallback
        if length:
            remaining = length
            while remaining > 0:
                data = environ['wsgi.input'].read(min(remaining, 65536))
                if not data:
                    raise IOError(
                        "Client disconnected (%s more bytes were expected)"
                        % remaining
                    )
                fileobj.write(data)
                remaining -= len(data)

        fileobj.seek(0)
        environ['wsgi.input'] = fileobj
        return fileobj, length
342206
function codegen(compiled, options) {
  const { code } = generate(t.file(t.program(compiled)), Object.assign({}, defaults, options));

  return code;
}
1087706
def tempdir(fun):
    '''

    '''
    def wrapper(*args, **kwargs):
        self = args[0]
        if os.path.isdir(self._tempdir):
            shutil.rmtree(self._tempdir)
        self._tempdir = tempfile.mkdtemp()
        # If the method raises an exception, delete the temporary dir
        try:
            retval = fun(*args, **kwargs)
        finally:
            shutil.rmtree(self._tempdir)
        if os.path.isdir(self._tempdir):
            shutil.rmtree(self._tempdir)
        return retval
    return wrapper
471932
def cmd_as_file(cmd, *args, **kwargs):
    """"""
    kwargs['stdout'] = subprocess.PIPE
    stdin = kwargs.pop('stdin', None)
    if isinstance(stdin, basestring):
        with tempfile.TemporaryFile() as stdin_file:
            stdin_file.write(stdin)
            stdin_file.seek(0)
            kwargs['stdin'] = stdin_file
            p = subprocess.Popen(cmd, *args, **kwargs)
    else:
        p = subprocess.Popen(cmd, *args, **kwargs)
    try:
        yield p.stdout
    finally:
        p.stdout.close()
        if p.wait():
            raise subprocess.CalledProcessError(p.returncode, cmd)
85337
def _new_temp_file(self, hint='warcrecsess'):
        ''''''
        return wpull.body.new_temp_file(
            directory=self._temp_dir, hint=hint
        )
170564
def generate(self, data, *args, **kwargs):
        
        with tempfile.TemporaryDirectory() as tmpdirname:
            self.options.setdefault('package_build_dir', tmpdirname)
            crawler = CrawlerScript(self.options)
            crawler.crawl(data, self.spider, *args, **kwargs)

            output_file = os.path.join(
                self.options['package_build_dir'], 'source', 'moear.mobi')
            with open(output_file, 'rb') as fh:
                content = fh.read()

        return content
95436
def get_file(self):
        
        content = self._load()
        if not content:
            return None
        filename = "temporary_file.bin"
        with open(filename, "wb") as file_name:
            file_name.write(content)
        return filename
278201
private static File createTempFile() throws IOException
  {
    File file = File.createTempFile(TMP_FILE_PREFIX, TMP_FILE_EXTENSION);
    file.deleteOnExit();
    return file;
  }
730046
def get_code(self, code):
        
        # code= [code] if isinstance(code,str) else
        return self.new(self.data.loc[(slice(None), code), :])
501949
def download(path, default_ext=None):
    
    key = "DOWNLOAD:{}".format(path)
    if not config.UPDATE and FILECACHE.get(key):
        return FILECACHE.get(key).decode('utf-8')

    config.LOGGER.info("\tDownloading {}".format(path))

    # Write file to temporary file
    with tempfile.TemporaryFile() as tempf:
        hash = write_and_get_hash(path, tempf)
        tempf.seek(0)

        # Get extension of file or default if none found
        extension = os.path.splitext(path)[1][1:].lower()
        if extension not in [key for key, value in file_formats.choices]:
            if default_ext:
                extension = default_ext
            else:
                raise IOError("No extension found: {}".format(path))

        filename = '{0}.{ext}'.format(hash.hexdigest(), ext=extension)

        copy_file_to_storage(filename, tempf)

        FILECACHE.set(key, bytes(filename, "utf-8"))

        return filename
930428
def tmp_file(*args, **kwargs):
    
    fileno, path = tempfile.mkstemp(*args, **kwargs)

    # create the file
    with open(path, "w") as f:
        f.write("")

    # yield it
    try:
        yield fileno, path
    finally:
        if os.path.exists(path):
            os.remove(path)
642707
def create(python, env_dir, system, prompt, bare, virtualenv_py=None):
    
    if not python or python == sys.executable:
        _create_with_this(
            env_dir=env_dir, system=system, prompt=prompt,
            bare=bare, virtualenv_py=virtualenv_py,
        )
    else:
        _create_with_python(
            python=python,
            env_dir=env_dir, system=system, prompt=prompt,
            bare=bare, virtualenv_py=virtualenv_py,
        )
1193119
def create(self):
        
        if self.path is not None:
            logger.debug(
                "Skipped creation of temporary directory: {}".format(self.path)
            )
            return
        # We realpath here because some systems have their default tmpdir
        # symlinked to another directory.  This tends to confuse build
        # scripts, so we canonicalize the path by traversing potential
        # symlinks here.
        self.path = os.path.realpath(
            tempfile.mkdtemp(prefix="pip-{}-".format(self.kind))
        )
        self._register_finalizer()
        logger.debug("Created temporary directory: {}".format(self.path))