-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
53 lines (40 loc) · 1.26 KB
/
build.py
File metadata and controls
53 lines (40 loc) · 1.26 KB
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
#!/usr/bin/env python
import os, sys, subprocess
from common.utils.Files import Files
class Config:
root = '.'
sources = ['backlog', 'loader', 'common']
########################################################
def test():
return subprocess.call("py.test", shell=True)
def clean():
for sourceDir in Config.sources:
Files.removeDirsRecursive(sourceDir, (lambda d: d == '__pycache__'))
Files.removeFilesRecursive(sourceDir, (lambda f: f.endswith('.pyc')))
def package():
for sourceDir in Config.sources:
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()