Skip to content

Commit

Permalink
Merge pull request #271 from openclimatefix/fix-folder-check
Browse files Browse the repository at this point in the history
use fsspec to check is path exists and is directory
  • Loading branch information
peterdudfield authored May 30, 2024
2 parents 3e950fd + 6a1de53 commit 028bf2e
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions satip/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import tempfile
import warnings
from pathlib import Path
from stat import S_ISDIR
from typing import Any, Tuple
from zipfile import ZipFile

Expand Down Expand Up @@ -98,16 +97,10 @@ def check_path_is_exists_and_directory(path) -> bool:
Returns:
Bool whether the path exists AND is a directory
"""
try:
mode = os.lstat(path).st_mode
except Exception as e:
log.error(f"Error caught during run: {e}", exc_info=True)
mode = os.lstat(path).st_mode
if S_ISDIR(mode):
return True
else:
log.error("Provided path is a file")
raise SystemExit(0)

fs = fsspec.open(path).fs
assert fs.exists(path)
assert fs.isdir(path)


def format_dt_str(datetime_string):
Expand Down

0 comments on commit 028bf2e

Please sign in to comment.