-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
30 lines (23 loc) · 787 Bytes
/
app.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
import sys
from time import process_time
from processor.processor import Processor
from processor.utils import setup_logger
log = setup_logger('logger')
def main():
"""
Usage:
python3 app.py input.txt' or 'python3 < input.txt'
"""
log.info('Begin processing...')
t = process_time()
processor = Processor()
# Accept input from two types of sources:
# a filename passed in command line arguments or STDIN.
with open(sys.argv[1], 'r') if len(sys.argv) > 1 else sys.stdin as f:
for line in f:
processor.parse_event(line)
log.info('Finished processing in {0:.3f} seconds'.format(process_time() - t))
summary = processor.generate_summary()
processor.write_output(summary)
if __name__ == "__main__":
main()