Changeset 3157

Show
Ignore:
Timestamp:
06/06/2007 10:52:08 AM (2 years ago)
Author:
ed
Message:

Modified the getTempFile() function to accept an optional directory parameter, specifying the directory in which the temp file is to be created. If it is omitted, the file is created in the default temporary items directory as before.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/dApp.py

    r3137 r3157  
    8080 
    8181 
    82     def getTempFile(self, ext=None, badChars=None): 
     82    def getTempFile(self, ext=None, badChars=None, directory=None): 
    8383        if ext is None: 
    8484            ext = "py" 
     
    8888        suffix = ".%s" % ext 
    8989        while not fname: 
    90             fd, tmpname = tempfile.mkstemp(suffix=suffix) 
     90            if directory is None: 
     91                fd, tmpname = tempfile.mkstemp(suffix=suffix) 
     92            else: 
     93                fd, tmpname = tempfile.mkstemp(suffix=suffix, dir=directory) 
    9194            os.close(fd) 
    9295            bad = [ch for ch in badChars if ch in os.path.split(tmpname)[1]]