OILS / devtools / tsv_stream.py View on Github | oilshell.org

43 lines, 14 significant
1#!/usr/bin/env python2
2"""
3tsv_stream.py
4
5Turn a log stream into a TSV file.
6
7Commands:
8
9| HEADER status elapsed_secs test test_HREF
10
11| ROW test=asdl/format_test.py test_HREF=asdl/format_test.py.txt
12
13| ADD status=0 elapsed_secs=0.01
14 # time-tsv can emit this format
15
16
17Later the header could be typed YTSV, for justification like
18
19| HEADER (status Int, elapsed_secs Float, test Str, test_HREF Str)
20
21
22"""
23from __future__ import print_function
24
25import sys
26
27
28def main(argv):
29 for i, line in enumerate(sys.stdin):
30 if i == 0:
31 print('header')
32
33 print(line.strip())
34
35 sys.stdout.flush()
36
37
38if __name__ == '__main__':
39 try:
40 main(sys.argv)
41 except RuntimeError as e:
42 print('FATAL: %s' % e, file=sys.stderr)
43 sys.exit(1)