Skip to content

Commit 5c32423

Browse files
fix HAMTIDE resource check flow when passing None
1 parent 827ace7 commit 5c32423

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

adcircpy/forcing/tides/hamtide.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ class HAMTIDE(TidalDataset):
1919
def __init__(self, hamtide_dataset_directory: PathLike = None):
2020
if hamtide_dataset_directory is None:
2121
hamtide_dataset_directory = self.OPENDAP_URL
22-
23-
if Path(hamtide_dataset_directory).exists():
24-
hamtide_dataset_directory = Path(hamtide_dataset_directory)
25-
if len(list(hamtide_dataset_directory.glob('*.nc'))) == 0:
26-
raise FileNotFoundError(f'no NetCDF files found at '
27-
f'"{hamtide_dataset_directory}"')
22+
else:
23+
try:
24+
if Path(hamtide_dataset_directory).exists():
25+
hamtide_dataset_directory = Path(hamtide_dataset_directory)
26+
if len(list(hamtide_dataset_directory.glob('*.nc'))) == 0:
27+
raise FileNotFoundError(f'no NetCDF files found at '
28+
f'"{hamtide_dataset_directory}"')
29+
except OSError:
30+
raise ValueError('given resource must be a local path')
2831

2932
super().__init__(hamtide_dataset_directory)
3033

0 commit comments

Comments
 (0)