Newer
Older
"""
gather_results: gather OAR results from one dir to one file called gathered_results in the same directory.
The result files should consist of lines and should have "stdout" in their name.
Usage:
gather_results -i IPATH
Options:
-h --help Show this screen.
-i --input-dir=<IPATH> Inut directory wher to find results
"""
from os import listdir
import os
from os.path import isfile, join
import docopt
if __name__ == '__main__':
arguments = docopt.docopt(__doc__)
mypath = os.path.abspath(arguments["--input-dir"])
onlyfiles = [os.path.join(mypath, f) for f in listdir(mypath) if isfile(join(mypath, f))]
count = 0
results = []
for f_name in onlyfiles:
if ".stdout" not in f_name:
continue
with open(f_name, "r") as f:
str_f = f.read().strip()
results.append(str_f)
with open(os.path.join(mypath, "gathered_results"), 'w') as f_w:
for s in results:
f_w.write(s)
f_w.write("\n")