-
Notifications
You must be signed in to change notification settings - Fork 26
/
merge_test.py
32 lines (27 loc) · 949 Bytes
/
merge_test.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
31
#coding:utf8
# merge_test.py MERGES all demo FORTRAN codes into one output_file, so you can build them as a test.
# files
import os, sys
import shutil
# utils
import re
def walk(search_path, output, appen):
if appen.strip(" ").strip("\n").strip("\r") == "n":
fout = open(output + ".for.test", "w+")
else:
fout = open(output + ".for.test", "a")
for path, dirs, files in os.walk(search_path):
for fn in files:
surfix = os.path.splitext(fn)[1][1:]
name = os.path.splitext(fn)[0]
if surfix in ["f90", "for", "f"]:
f = open(path + "/" + fn, "r")
fout.write(f.read())
fout.write("\n")
f.close()
fout.close()
if __name__ == '__main__':
if len(sys.argv) < 4:
print "gen_test.py <tests_dir> <output_file> <append> = [y/n]"
else:
walk(sys.argv[1], sys.argv[2], sys.argv[3])