-
Notifications
You must be signed in to change notification settings - Fork 0
/
delivery-cleanup.py
47 lines (33 loc) · 1.17 KB
/
delivery-cleanup.py
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
47
#!/usr/bin/python
# this script copies the working folders and removes files not needed for final delivery
import os
import sys
import shutil
def scandirs(path):
# this will be the new folder that working files are copied to
deliverables_path = os.path.join(path, 'deliverables')
archive_file_name = 'deliverables'
archive_type = 'zip'
# try to delete deliverables path if it exists already
try:
shutil.rmtree(deliverables_path)
except FileNotFoundError:
print("could not delete " + deliverables_path)
# copy working files to deliverables
shutil.copytree(path, deliverables_path)
print("copied to " + deliverables_path)
# now delete junk
for root, dirs, files in os.walk(deliverables_path):
for currentFile in files:
exts=('.swf', '.jpg', '.png')
if not any(currentFile.lower().endswith(ext) for ext in exts):
path = os.path.join(root, currentFile)
print("delete file: " + path)
os.remove(path)
for currentDir in dirs:
if "assets" in currentDir:
print("delete dir: " + currentDir)
shutil.rmtree(os.path.join(root, currentDir))
# zip up the new folder
shutil.make_archive(archive_file_name, archive_type, deliverables_path)
scandirs('./')