All Samples(1540) | Call(1425) | Derive(0) | Import(115)
Create and return a temporary file. Arguments: 'prefix', 'suffix', 'dir' -- as for mkstemp. 'mode' -- the mode argument to os.fdopen (default "w+b"). 'bufsize' -- the buffer size argument to os.fdopen (default -1). 'delete' -- whether the file is deleted on close (default True). The file is created as mkstemp() would do it. Returns an object with a file-like interface; the name of the file is accessible as file.name. The file will be automatically deleted when it is closed unless the 'delete' argument is set to False.
def NamedTemporaryFile(mode='w+b', bufsize=-1, suffix="",
prefix=template, dir=None, delete=True):
"""Create and return a temporary file.
Arguments:
'prefix', 'suffix', 'dir' -- as for mkstemp.
'mode' -- the mode argument to os.fdopen (default "w+b").
'bufsize' -- the buffer size argument to os.fdopen (default -1).
'delete' -- whether the file is deleted on close (default True).
The file is created as mkstemp() would do it.
Returns an object with a file-like interface; the name of the file
is accessible as file.name. The file will be automatically deleted
when it is closed unless the 'delete' argument is set to False.
"""
if dir is None:
dir = gettempdir()
if 'b' in mode:
flags = _bin_openflags
else:
flags = _text_openflags
# Setting O_TEMPORARY in the flags causes the OS to delete
# the file when it is closed. This is only supported by Windows.
if _os.name == 'nt' and delete:
flags |= _os.O_TEMPORARY
(fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
file = _os.fdopen(fd, mode, bufsize)
return _TemporaryFileWrapper(file, name, delete)
# Stdlib import warnings from tempfile import NamedTemporaryFile from os.path import join as pjoin # Third party
for n in tcons:
tempdict = {}
for v in ['sd', 't', 'effect']:
tempdict[v] = np.memmap(NamedTemporaryFile(prefix='%s%s.nii' \
% (n,v)), dtype=np.float,
shape=volshape, mode='w+')
output[n] = tempdict
for n in fcons:
output[n] = np.memmap(NamedTemporaryFile(prefix='%s%s.nii' \
src/n/i/NiPy-OLD-HEAD/examples/fiac/fiac_example.py NiPy-OLD(Download)
# Stdlib import warnings from tempfile import NamedTemporaryFile from os.path import join as pjoin # Third party
for n in tcons:
tempdict = {}
for v in ['sd', 't', 'effect']:
tempdict[v] = np.memmap(NamedTemporaryFile(prefix='%s%s.nii' \
% (n,v)), dtype=np.float,
shape=volshape, mode='w+')
output[n] = tempdict
for n in fcons:
output[n] = np.memmap(NamedTemporaryFile(prefix='%s%s.nii' \
src/f/l/flickrgetstats-HEAD/trunk/Eclipse/FlickrStatistics/flickr/statistics/get/aggregate.py flickrgetstats(Download)
if nViewsTotal == 0:
return #no views for this day
# create output file only if there is content
fout = tempfile.NamedTemporaryFile(mode='w', suffix='.csv', prefix=sDay + '-flickr-', dir=sFolder, delete=False)
sFoutTmpName = fout.name
if self.bVerbose:
print 'tmp file "%s"' % sFoutTmpName
src/w/a/waterworks-0.2.5/waterworks/Files.py waterworks(Download)
def sortedfile(filename, mode='r', sortcmd='sort -n'):
"""Returns a file-like object which contains a sorted version of
filename. Note that the file-like object returned is a
NamedTemporaryFile and will be deleted when it goes out of scope."""
import pipes, tempfile
tf = tempfile.NamedTemporaryFile()
else: # dir
return tempfile.mkdtemp(suffix=suffix, prefix=prefix, dir=dir)
else:
return tempfile.NamedTemporaryFile(mode=mode, suffix=suffix,
prefix=prefix, dir=dir)
def derived_named_tempfile(filename, **tempfile_options):
src/f/l/flickrgetstats-HEAD/Eclipse/FlickrStatistics/flickr/statistics/get/aggregate.py flickrgetstats(Download)
if nViewsTotal == 0:
return #no views for this day
# create output file only if there is content
fout = tempfile.NamedTemporaryFile(mode='w', suffix='.csv', prefix=sDay + '-flickr-', dir=sFolder, delete=False)
sFoutTmpName = fout.name
if self.bVerbose:
print 'tmp file "%s"' % sFoutTmpName
src/f/i/fileinfo-0.3.3/src/fileinfo/guidjango/tmpfile.py fileinfo(Download)
from os.path import expanduser, normpath
from tempfile import NamedTemporaryFile
pickledDataPath = normpath(expanduser("~/fileinfo_data_for_django.pickle"))
if False:
homeDir = normpath(expanduser("~"))
f = NamedTemporaryFile(
mode="w", suffix=".pickle", prefix="fileinfo_data_", dir=homeDir)
src/c/o/cocoafip-HEAD/seccion_django/cocorece/views.py cocoafip(Download)
# El TA vencio. Hay que solicitarlo nuevamente
file_pk = tempfile.NamedTemporaryFile(suffix = dictjson["empresa_cuit"] + ".pk", prefix = "pk", delete = False, \
dir = configuracion.ruta_tmp + "cocorece")
file_pk.write(dictjson["empresa_clave_privada"])
file_crt = tempfile.NamedTemporaryFile(suffix = dictjson["empresa_cuit"] + ".crt", prefix = "cert", delete = False, \
src/p/y/Python-Policy-Filter-HEAD/PPFilter/enqueuer.py Python-Policy-Filter(Download)
def enqueue(message):
data = message['data']
try:
qFile = tempfile.NamedTemporaryFile(dir=config.temp_directory, prefix='q', suffix='.tmp', delete=False)
qFile.write(data)
src/j/a/Jamendo-Console-Player-HEAD/jam_player.py Jamendo-Console-Player(Download)
def _download(self,trackUrl): track = wget(trackUrl) if track != None: try: tmpfile = tempfile.NamedTemporaryFile(mode='wb',prefix='jamendo',suffix='.mp3', delete=False) file(tmpfile.name,'w+b').write(track) except IOError:
src/p/l/Plml-HEAD/util.py Plml(Download)
from tempfile import NamedTemporaryFile from anydbm import open as dbopen from xml.parsers import expat from urllib2 import urlopen from zlib import crc32 import collections import subprocess
def verify_gnupg(self, sig):
sigfile = NamedTemporaryFile('w',suffix='.sig',prefix='plml',delete=False)
name = sigfile.name
sigfile.close()
gnupg = subprocess.Popen(['gpg', '--verify', name, '-'],
stdin=subprocess.PIPE,
stderr=subprocess.PIPE,
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next