Create a temporary file in the '.faz' directory for
            the code to feed to the interpreter.
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))
159475
def _prepare_temp_dir(self):
    """"""
    shell_call(['rm', '-rf', os.path.join(self._temp_dir, '*')])
    # NOTE: we do not create self._extracted_submission_dir
    # this is intentional because self._tmp_extracted_dir or it's subdir
    # will be renames into self._extracted_submission_dir
    os.mkdir(self._tmp_extracted_dir)
    os.mkdir(self._sample_input_dir)
    os.mkdir(self._sample_output_dir)
    # make output dir world writable
    shell_call(['chmod', 'a+rwX', '-R', self._sample_output_dir])
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)
124419
def make_dist(toxinidir, toxdir, package):
    """"""
    dist = os.path.join(toxdir, "dist")
    # Suppress warnings.
    success = safe_shell_out(["python", "setup.py", "sdist", "--quiet",
                              "--formats=zip", "--dist-dir", dist],
                             cwd=toxinidir)
    if success:
        return os.path.join(dist, package + ".zip")
308590
def _generate_to_tempfile(self, generator):
    """"""
    with temporary_file(cleanup=False, binary_mode=False) as output:
      generator.write(output)
      return output.name
529924
def tmpfile(*args, **kwargs):
    
    (fd, fname) = tempfile.mkstemp(*args, **kwargs)
    try:
        yield fname
    finally:
        os.close(fd)
        if os.path.exists(fname):
            os.remove(fname)
826519
def create_readme_with_long_description():
    '''
    '''
    this_dir = os.path.abspath(os.path.dirname(__file__))

    readme_md = os.path.join(this_dir, 'README.md')
    readme = os.path.join(this_dir, 'README')

    if os.path.exists(readme_md):
        # this is the case when running `python setup.py sdist`
        if os.path.exists(readme):
            os.remove(readme)

        try:
            import pypandoc
            long_description = pypandoc.convert(readme_md, 'rst', format='md')
        except(ImportError):
            with open(readme_md, encoding='utf-8') as in_:
                long_description = in_.read()

        with open(readme, 'w') as out:
            out.write(long_description)
    else:
        # this is in case of `pip install fabsetup-x.y.z.tar.gz`
        with open(readme, encoding='utf-8') as in_:
            long_description = in_.read()

    return long_description
189609
def create_ar (archive, compression, cmd, verbosity, interactive, filenames):
    """"""
    opts = 'rc'
    if verbosity > 1:
        opts += 'v'
    cmdlist = [cmd, opts, archive]
    cmdlist.extend(filenames)
    return cmdlist
880358
def _save_stdin(self, stdin):
		
		self.temp_dir = TemporaryDirectory()
		file_path = os.path.join(self.temp_dir.name, 'dataset')

		try:
			with open(file_path, 'w') as f:
				for line in stdin:
					f.write(line)
		except TypeError:
			self.temp_dir.cleanup()
			raise ValueError('Could not read stdin')

		return file_path
838656
def make_temp(text):
        
        import tempfile
        (handle, path) = tempfile.mkstemp(text=True)
        os.close(handle)
        afile = File(path)
        afile.write(text)
        return afile
424066
def new_temp_file(directory=None, hint=''):
    ''''''
    return tempfile.NamedTemporaryFile(
        prefix='tmp-wpull-{0}-'.format(hint), suffix='.tmp', dir=directory)
1213319
private synchronized File createTemp(File workingDirectory) throws IOException {
        if (workingDirectory == null) {
            return createTempDir();
        }
        else {
            workingDirectory.mkdirs();
            return workingDirectory;
        }
    }
1052904
def copy_to_tmp(source):
    
    tmp_dir = tempfile.mkdtemp()
    # Use pathlib because os.path.basename is different depending on whether
    # the path ends in a /
    p = pathlib.Path(source)
    dirname = p.name or 'temp'
    new_dir = os.path.join(tmp_dir, dirname)
    if os.path.isdir(source):
        shutil.copytree(source, new_dir)
    else:
        shutil.copy2(source, new_dir)
    return new_dir
1066658
def serve(content):
    """"""
    temp_folder = tempfile.gettempdir()
    temp_file_name = tempfile.gettempprefix() + str(uuid.uuid4()) + ".html"
    # Generate a file path with a random name in temporary dir
    temp_file_path = os.path.join(temp_folder, temp_file_name)

    # save content to temp file
    save(temp_file_path, content)

    # Open templfile in a browser
    webbrowser.open("file://{}".format(temp_file_path))

    # Block the thread while content is served
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        # cleanup the temp file
        os.remove(temp_file_path)
672050
def _setup_py_run_from_dir(root_dir, py_interpreter):
    """"""
    data = {}
    with _enter_single_subdir(root_dir) as single_subdir:
        if not os.path.exists("setup.py"):
            raise Exception("'setup.py' does not exist in '%s'" % (
                single_subdir))
        # generate a temporary json file which contains the metadata
        output_json = tempfile.NamedTemporaryFile()
        cmd = "%s setup.py -q --command-packages metaextract " \
              "metaextract -o %s " % (py_interpreter, output_json.name)
        try:
            subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
        except subprocess.CalledProcessError:
            # try again with a encoding in setup.py
            _set_file_encoding_utf8("setup.py")
            subprocess.check_output(cmd, shell=True)

        # read json file and return data
        with open(output_json.name, "r") as f:
            data = json.loads(f.read())

        # sort some of the keys if the dict values are lists
        for key in ['data_files', 'entry_points', 'extras_require',
                    'install_requires', 'setup_requires', 'scripts',
                    'tests_require', 'tests_suite']:
            if key in data['data'] and isinstance(data['data'][key], list):
                data['data'][key] = sorted(data['data'][key])
    return data
532510
def tmpfile(prefix, direc):
    """"""
    return tempfile.mktemp(prefix=prefix, suffix='.pdb', dir=direc)
1096190
def provide_temporary_scripts_path(self):
        """"""
        if len(self.options.temporary_scripts_path) > 0:
            if os.path.isfile(self.options.temporary_scripts_path):
                self.logger.error("Error: configured script path seems to be a file!")
                # it's ok to leave because called before the collector runs
                sys.exit(1)

            if not os.path.isdir(self.options.temporary_scripts_path):
                os.makedirs(self.options.temporary_scripts_path)