-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathant-tools.py
More file actions
executable file
·54 lines (35 loc) · 1.02 KB
/
ant-tools.py
File metadata and controls
executable file
·54 lines (35 loc) · 1.02 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
54
#!/usr/bin/env python
import io, os, sys, json
from subprocess import Popen, PIPE
BIN = "ant-tools"
class AntReader(object):
def __init__(self, ant_path):
if not ant_path:
raise Exception("An .ant file must be specified")
self.ant_path = ant_path
def Load(self):
for line in call_bin(get_bin_path(), self.ant_path):
yield json.loads(line)
def Validate(self):
for line in call_bin(get_bin_path(), [self.ant_path, "--validate"]):
print line
def PrintStats(self):
for line in call_bin(get_bin_path(), [self.ant_path, "--stats"]):
print line
def main():
args = sys.argv[1:]
if not args:
args = ['']
for line in call_bin(get_bin_path(), args):
if not line:
continue
print line
def get_bin_path():
return os.path.join(os.getcwd(), BIN)
def call_bin(command, args):
command_args = [command] + args
process = Popen(command_args, stdout=PIPE)
for line in io.open(process.stdout.fileno()):
yield line.rstrip('\n')
if __name__ == '__main__':
main()