add files.overwriting_move()
This commit is contained in:
parent
76e37f0e75
commit
6ff7ff09b5
1 changed files with 13 additions and 0 deletions
|
@ -100,6 +100,19 @@ def count_lines(path):
|
|||
return lines
|
||||
|
||||
|
||||
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):
|
||||
"""
|
||||
Returns a resource file path. ``path`` is assumed either to be a package
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue