Revision 76ab5558 lib/backend.py
b/lib/backend.py | ||
---|---|---|
48 | 48 |
return ssh.SshRunner() |
49 | 49 |
|
50 | 50 |
|
51 |
def _CleanDirectory(path): |
|
51 |
def _CleanDirectory(path, exclude=[]): |
|
52 |
"""Removes all regular files in a directory. |
|
53 |
|
|
54 |
@param exclude: List of files to be excluded. |
|
55 |
@type exclude: list |
|
56 |
|
|
57 |
""" |
|
52 | 58 |
if not os.path.isdir(path): |
53 | 59 |
return |
60 |
|
|
61 |
# Normalize excluded paths |
|
62 |
exclude = [os.path.normpath(i) for i in exclude] |
|
63 |
|
|
54 | 64 |
for rel_name in utils.ListVisibleFiles(path): |
55 |
full_name = os.path.join(path, rel_name) |
|
65 |
full_name = os.path.normpath(os.path.join(path, rel_name)) |
|
66 |
if full_name in exclude: |
|
67 |
continue |
|
56 | 68 |
if os.path.isfile(full_name) and not os.path.islink(full_name): |
57 | 69 |
utils.RemoveFile(full_name) |
58 | 70 |
|
Also available in: Unified diff