-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean.py
More file actions
executable file
·46 lines (37 loc) · 881 Bytes
/
clean.py
File metadata and controls
executable file
·46 lines (37 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
"""
clean.py - Clean up Webware installation directory.
Removes all derived and temporary files.
This will work on all operating systems.
"""
# The files that shall be removed:
files = '''
*~
*.bak
*.pyc
*.pyo
CGIWrapper/Errors.csv
CGIWrapper/Scripts.csv
CGIWrapper/ErrorMsgs/*.html
WebKit/*.pid
WebKit/*.address
WebKit/Logs/*.csv
WebKit/ErrorMsgs/*.html
'''
import os
from glob import glob
def remove(pattern):
for name in glob(pattern):
os.remove(name)
def walk_remove(pattern, dirname, names):
pattern = os.path.join(dirname, pattern)
remove(pattern)
if __name__ == '__main__':
print "Cleaning up..."
for pattern in files.splitlines():
if pattern:
print pattern
if '/' in pattern:
remove(pattern)
else:
os.path.walk('.', walk_remove, pattern)