Changeset - 3203b428288d
[Not reviewed]
0 1 0
Lance Edgar (lance) - 11 years ago 2013-06-08 14:57:50
lance@edbob.org
Added `files.overwriting_move()` convenience function.
1 file changed with 13 insertions and 0 deletions:
0 comments (0 inline, 0 general)
rattail/files.py
Show inline comments
 
@@ -98,6 +98,19 @@ def locking_copy(src, dst):
 
        shutil.copy(src, dst)
 

	
 

	
 
def overwriting_move(src, dst):
 
    """
 
    Convenience function which is equivalent to ``shutil.move()``, except it
 
    will cause the destination file to be overwritten if it exists.
 
    """
 

	
 
    if os.path.isdir(dst):
 
        dst = os.path.join(dst, os.path.basename(src))
 
    if os.path.exists(dst):
 
        os.remove(dst)
 
    shutil.move(src, dst)
 

	
 

	
 
def resource_path(path):
 
    """
 
    Obtain a resource file path, extracting the resource and/or coercing the
0 comments (0 inline, 0 general)