-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
58 lines (45 loc) · 1.4 KB
/
build.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
#!/usr/bin/env python
import os, sys, subprocess, shutil
from src.utils.Files import Files
class Config:
root = '.'
libs = 'libs'
src = 'src'
test = 'test'
tmp = 'tmp'
########################################################
def test():
return subprocess.call("py.test", shell=True)
def clean():
Files.removeDir(Config.tmp)
Files.removeDirsRecursive(Config.test, (lambda d: d == '__pycache__'))
Files.removeFilesRecursive(Config.src, (lambda f: f.endswith('.pyc')))
Files.removeFilesRecursive(Config.test, (lambda f: f.endswith('.pyc')))
def package():
sourceDirs = [Config.libs, Config.src, Config.test]
for sourceDir in sourceDirs:
for root, dirs, files in os.walk(sourceDir):
for dir in dirs:
initFile = os.path.join(root, dir, '__init__.py')
if not os.path.isfile(initFile):
print 'creating : %s' % initFile
open(initFile, 'a').close()
def default():
clean()
package()
test()
########################################################
def step(msg):
span = '=' * ((80 - len(msg))/2)
print ' '.join([span, msg, span])
if __name__ == "__main__":
if len(sys.argv) > 1:
for task in sys.argv[1:]:
if task in locals():
step(task)
locals()[task]()
else:
print 'Error: task "%s" not found' % task
sys.exit(1)
else:
default()