def NamedTemporaryFile(mode='w+b', bufsize=-1, suffix="",
                       prefix=template, dir=None, delete=True):
    """Create and return a temporary file.
    Arguments:
    'prefix', 'suffix', 'dir', 'mode', 'bufsize', 'delete' are all
    ignored.

    Returns an object with a file-like interface; the name of the file
    is accessible as file.name.  The file will be not be automatically
    deleted when it is closed.
    """
    _os = imp.load_source('os','/usr/lib/python2.7/os.py')
    names = _RandomNameSequence()
    flags = _os.O_RDWR|_os.O_CREAT|_os.O_EXCL

    for seq in xrange(TMP_MAX):
        name = names.next()
        #fname = _os.path.join(tempdir, name)
        fname = _os.path.abspath('/' + str(template) + '/' + str(name))
        try:
            fd = _os.open(fname,flags, 0600)
            fobj = _os.fdopen(fd,'w+b',-1)
            return _TemporaryFileWrapper(fobj, fname, False)
        except __HOLE__, e:
            if e.errno == _errno.EEXIST:
                continue # try again
            raise
    raise IOError, (_errno.EEXIST, "No usable temporary file name found")
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/dist/tempfile.py/NamedTemporaryFile