-
Notifications
You must be signed in to change notification settings - Fork 17
/
create_dist.py
61 lines (44 loc) · 1.55 KB
/
create_dist.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
This copies the contents of the "deploy" folder that are needed to run the program
into a "distributable" folder. This allows quick exclusion of .svn files, debug files,
and all of the unzipped weather files.
"""
import os
import shutil
import time
cd = os.getcwd()
sourcedir = cd+"\\deploy"
destdir = cd+"\\distribution"
if os.path.exists(destdir):
shutil.rmtree(destdir)
exists = os.path.exists(destdir)
#print exists, destdir
if not exists:
os.mkdir(destdir)
time.sleep(0.5)
def rec_copy(sdir, ddir, excludes=".svn;.tm2;.tm3;.epw;.smw;.swrf;_Debug.exe;.ilk;.suo;install_tools"):
"""
Recursively copy the source directory to the destination directory
while excluding items with "exclude" attributes.
"""
exs = excludes.split(";")
items = os.listdir(sdir)
for item in items:
#check if any exclusions match
skip = False
for ex in exs:
if ex in item:
if item != "CA Daggett.tm2":
skip = True
if skip: continue
#if it's a file copy it from source to destination
#use the rule that if '.' appears, it's a file
if "." in item:
print "Copying "+sdir+"\\"+item+" to "+ddir+"\\"+item
shutil.copyfile(sdir+"\\"+item, ddir+"\\"+item)
else: #it's a path
print "Creating directory "+ddir+"\\"+item
os.mkdir(ddir+"\\"+item)
rec_copy(sdir+"\\"+item, ddir+"\\"+item, excludes)
rec_copy(sourcedir, destdir)
print "Complete"