Skip to content

Commit b4b41a5

Browse files
authored
Print the wrong filename when not found (#427)
* Print the wrong filename when not found * Fix it
1 parent e3eed9e commit b4b41a5

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pysteps/io/archive.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ def _find_matching_filename(
9494
date, root_path, path_fmt, fn_pattern, fn_ext, silent=False
9595
):
9696
path = _generate_path(date, root_path, path_fmt)
97-
fn = None
9897

9998
if os.path.exists(path):
10099
fn = datetime.strftime(date, fn_pattern) + "." + fn_ext
@@ -111,15 +110,15 @@ def _find_matching_filename(
111110
fn = os.path.join(path, fn)
112111

113112
if os.path.exists(fn):
114-
fn = fn
113+
return fn
115114
else:
116-
fn = None
117115
if not silent:
118-
print("file not found: %s" % fn)
119-
elif not silent:
120-
print("path", path, "not found.")
121-
122-
return fn
116+
print(f"file not found: {fn}")
117+
return None
118+
else:
119+
if not silent:
120+
print(f"path not found: {path}")
121+
return None
123122

124123

125124
def _generate_path(date, root_path, path_format):

0 commit comments

Comments
 (0)