forked from esilgard/argos_nlp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
output_results.py
27 lines (25 loc) · 1.08 KB
/
output_results.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
'''author@esilgard'''
#
# Copyright (c) 2013-2016 Fred Hutchinson Cancer Research Center
#
# Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
#
__version__ = 'output_results1.0'
import json, sys
def main(output_file_name, output):
'''
output warnings and results in json format to CWD in the file provided
'''
try:
file_object = open(output_file_name, 'wb')
except IOError:
sys.stderr.write('FATAL ERROR: path to output file ' + output_file_name + ' not found')
return 'FATAL ERROR: path to output file ' + output_file_name + ' not found'
try:
with file_object as output_file:
pretty_dump = json.dumps(output, sort_keys=True, indent=4, separators=(',', ': '))
output_file.write(pretty_dump)
except SyntaxError:
sys.stderr.write('FATAL ERROR: problem with output filestream to file object "'\
+ output_file_name + '" --- sys.exec_info = '+ str(sys.exc_info()))
return 'FATAL ERROR: path to output file ' + output_file_name + ' not found'