~pythonregexp2.7/python/issue2636-09-01+10

« back to all changes in this revision

Viewing changes to Lib/tempfile.py

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-05-24 18:56:40 UTC
  • mfrom: (39055.1.22 Regexp-2.6)
  • Revision ID: darklord@timehorse.com-20080524185640-59vz6l1f7qgixgal
Merged in changes from the Single-Loop Engine branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
import errno as _errno
34
34
from random import Random as _Random
35
35
 
36
 
if _os.name == 'mac':
37
 
    import Carbon.Folder as _Folder
38
 
    import Carbon.Folders as _Folders
39
 
 
40
36
try:
41
37
    from cStringIO import StringIO as _StringIO
42
 
except:
 
38
except ImportError:
43
39
    from StringIO import StringIO as _StringIO
44
40
 
45
41
try:
82
78
 
83
79
template = "tmp"
84
80
 
85
 
tempdir = None
86
 
 
87
81
# Internal routines.
88
82
 
89
83
_once_lock = _allocate_lock()
155
149
        if dirname: dirlist.append(dirname)
156
150
 
157
151
    # Failing that, try OS-specific locations.
158
 
    if _os.name == 'mac':
159
 
        try:
160
 
            fsr = _Folder.FSFindFolder(_Folders.kOnSystemDisk,
161
 
                                              _Folders.kTemporaryFolderType, 1)
162
 
            dirname = fsr.as_pathname()
163
 
            dirlist.append(dirname)
164
 
        except _Folder.error:
165
 
            pass
166
 
    elif _os.name == 'riscos':
 
152
    if _os.name == 'riscos':
167
153
        dirname = _os.getenv('Wimp$ScrapDir')
168
154
        if dirname: dirlist.append(dirname)
169
155
    elif _os.name == 'nt':
259
245
tempdir = None
260
246
 
261
247
def gettempdir():
262
 
    """Accessor for tempdir.tempdir."""
 
248
    """Accessor for tempfile.tempdir."""
263
249
    global tempdir
264
250
    if tempdir is None:
265
251
        _once_lock.acquire()
271
257
    return tempdir
272
258
 
273
259
def mkstemp(suffix="", prefix=template, dir=None, text=False):
274
 
    """mkstemp([suffix, [prefix, [dir, [text]]]])
275
 
    User-callable function to create and return a unique temporary
 
260
    """User-callable function to create and return a unique temporary
276
261
    file.  The return value is a pair (fd, name) where fd is the
277
262
    file descriptor returned by os.open, and name is the filename.
278
263
 
309
294
 
310
295
 
311
296
def mkdtemp(suffix="", prefix=template, dir=None):
312
 
    """mkdtemp([suffix, [prefix, [dir]]])
313
 
    User-callable function to create and return a unique temporary
 
297
    """User-callable function to create and return a unique temporary
314
298
    directory.  The return value is the pathname of the directory.
315
299
 
316
300
    Arguments are as for mkstemp, except that the 'text' argument is
341
325
    raise IOError, (_errno.EEXIST, "No usable temporary directory name found")
342
326
 
343
327
def mktemp(suffix="", prefix=template, dir=None):
344
 
    """mktemp([suffix, [prefix, [dir]]])
345
 
    User-callable function to return a unique temporary file name.  The
 
328
    """User-callable function to return a unique temporary file name.  The
346
329
    file is not created.
347
330
 
348
331
    Arguments are as for mkstemp, except that the 'text' argument is