File tree Expand file tree Collapse file tree 1 file changed +20
-14
lines changed
Expand file tree Collapse file tree 1 file changed +20
-14
lines changed Original file line number Diff line number Diff line change 4040# ===========================================================================
4141import os
4242import re
43+ import warnings
4344from esmfRegion import ESMFRegion
4445import time
4546
@@ -76,22 +77,27 @@ def collect_runtime_tot(
7677
7778def _list_esmf_files (dir_path , profile_prefix , esmf_summary , summary_profile ):
7879 """Lists ESMF files based on a prefix."""
79- files = os .listdir (dir_path )
80- if not esmf_summary :
81- # ESMF_Profile.xxxx
82- matching_files = [
83- file
84- for file in files
85- if file .startswith (profile_prefix ) and file != summary_profile
80+ try :
81+ files = os .listdir (dir_path )
82+ if not esmf_summary :
83+ # ESMF_Profile.xxxx
84+ matching_files = [
85+ file
86+ for file in files
87+ if file .startswith (profile_prefix ) and file != summary_profile
88+ ]
89+ matching_files .sort (key = lambda x : int (x [len (profile_prefix ) :]))
90+ else :
91+ # ESMF_Profile.summary
92+ matching_files = [summary_profile ]
93+
94+ matching_files_path = [
95+ os .path .join (dir_path , matching_file ) for matching_file in matching_files
8696 ]
87- matching_files .sort (key = lambda x : int (x [len (profile_prefix ) :]))
88- else :
89- # ESMF_Profile.summary
90- matching_files = [summary_profile ]
97+ except FileNotFoundError :
98+ warnings .warn (f"Directory { dir_path } does not exist! Skipping!" )
99+ matching_files_path = []
91100
92- matching_files_path = [
93- os .path .join (dir_path , matching_file ) for matching_file in matching_files
94- ]
95101 return matching_files_path
96102
97103
You can’t perform that action at this time.
0 commit comments