FV3-JEDI
update_output.py
Go to the documentation of this file.
1 # (C) Copyright 2017-2020 UCAR
2 #
3 # This software is licensed under the terms of the Apache Licence Version 2.0
4 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 
6 import os
7 import re
8 
9 test_string = 'Test :'
10 
11 # Loop over log files
12 runfiles = os.listdir()
13 for runfile in runfiles:
14 
15  # Check if the file is a log file
16  if runfile[-4:] == '.run':
17 
18  # Output file
19  runreffile = runfile[0:-3]+'ref'
20  outfile = open(runreffile, "w")
21 
22  # Open file
23  for line in open(runfile, 'r'):
24 
25  if re.search(test_string, line):
26  outfile.write(line)
27  if line == None:
28  print('no matches found')
29 
30  outfile.close()
31 
32  # Grep for test string
33  #print(line)