Changeset - 5b0182470cfc
[Not reviewed]
0 1 0
Lance Edgar (lance) - 11 years ago 2013-05-22 23:40:43
lance@edbob.org
Added `temp_path()` function in `files` module.
1 file changed with 15 insertions and 0 deletions:
0 comments (0 inline, 0 general)
rattail/files.py
Show inline comments
 
@@ -28,9 +28,11 @@
 
This module contains various utility functions for use with the filesystem.
 
"""
 

	
 
import os
 
import os.path
 
import shutil
 
import lockfile
 
import tempfile
 
from datetime import datetime
 

	
 
import pkg_resources
 
@@ -116,3 +118,16 @@ def resource_path(path):
 
    if not os.path.isabs(path) and ':' in path:
 
        return pkg_resources.resource_filename(*path.split(':'))
 
    return path
 

	
 

	
 
def temp_path(suffix='.tmp', prefix='rattail.', **kwargs):
 
    """
 
    Returns a path for a temporary file.
 

	
 
    This is a convenience function which wraps ``tempfile.mkstemp()``.  The
 
    meaning of the arguments is the same.
 
    """
 

	
 
    fd, path = tempfile.mkstemp(suffix, prefix, **kwargs)
 
    os.close(fd)
 
    return path
0 comments (0 inline, 0 general)