File tree 1 file changed +20
-14
lines changed
1 file changed +20
-14
lines changed Original file line number Diff line number Diff line change 40
40
# ===========================================================================
41
41
import os
42
42
import re
43
+ import warnings
43
44
from esmfRegion import ESMFRegion
44
45
import time
45
46
@@ -76,22 +77,27 @@ def collect_runtime_tot(
76
77
77
78
def _list_esmf_files (dir_path , profile_prefix , esmf_summary , summary_profile ):
78
79
"""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
86
96
]
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 = []
91
100
92
- matching_files_path = [
93
- os .path .join (dir_path , matching_file ) for matching_file in matching_files
94
- ]
95
101
return matching_files_path
96
102
97
103
You can’t perform that action at this time.
0 commit comments