Skip to content

Commit

Permalink
support nested urls and ignore preview/* (#49)
Browse files Browse the repository at this point in the history
* also ignore everything in the `preview` directory

* update the documented list of ignores
  • Loading branch information
keewis authored May 12, 2023
1 parent c7f1b75 commit d2f7669
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions safe_rcm/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,26 @@ def execute(tree, f, path):


def ignored_file(path, ignores):
return any(fnmatchcase(posixpath.basename(path), ignore) for ignore in ignores)
ignored = [
fnmatchcase(path, ignore) or fnmatchcase(posixpath.basename(path), ignore)
for ignore in ignores
]
return any(ignored)


def open_rcm(
url,
*,
backend_kwargs=None,
manifest_ignores=["*.pdf", "*.html", "*.xslt", "*.png", "*.kml", "*.txt"],
manifest_ignores=[
"*.pdf",
"*.html",
"*.xslt",
"*.png",
"*.kml",
"*.txt",
"preview/*",
],
**dataset_kwargs,
):
"""read SAFE files of the radarsat constellation mission (RCM)
Expand All @@ -45,7 +57,8 @@ def open_rcm(
----------
url : str
backend_kwargs : mapping
manifest_ignores : list of str, default: ["*.pdf", "*.html", "*.xslt", "*.png", "*.kml", "*.txt"]
manifest_ignores : list of str, default: ["*.pdf", "*.html", "*.xslt", "*.png", \
"*.kml", "*.txt", "preview/*"]
Globs that match files from the manifest that are allowed to be missing.
**dataset_kwargs
Keyword arguments forwarded to `xr.open_dataset`, used to open
Expand Down Expand Up @@ -73,7 +86,7 @@ def open_rcm(
path
for path in declared_files
if not ignored_file(path, manifest_ignores)
and not mapper.fs.exists(f"{url}/{path}")
and not mapper.fs.exists(mapper._key_to_str(path))
]
if missing_files:
raise ExceptionGroup(
Expand Down

0 comments on commit d2f7669

Please sign in to comment.