Skip to content

Commit

Permalink
Do path normalisation globally for prepare tools
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyh committed May 20, 2022
1 parent cd80d22 commit 0a2ba64
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions eodatasets3/prepare/sentinel_l1_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,6 @@ def main(
dry_run: bool,
index_to_odc: bool,
):
output_base = normalise_path(output_base) if output_base else None

if sys.argv[1] == "sentinel-l1c":
warnings.warn(
"Command name 'sentinel-l1c-prepare' is deprecated: remove the 'c', and use `sentinel-l1-prepare`"
Expand All @@ -545,7 +543,10 @@ def main(
if datasets_path:
datasets = [
*datasets,
*(Path(p.strip()) for p in (datasets_path.read_text().splitlines())),
*(
normalise_path(p.strip())
for p in (datasets_path.read_text().splitlines())
),
]

_LOG.info(f"{len(datasets)} paths(s) to process using {workers} worker(s))")
Expand Down Expand Up @@ -587,7 +588,6 @@ def find_jobs() -> Iterable[Job]:
datasets, label="Preparing metadata", show_pos=True
) as progress:
for i, input_path in enumerate(progress):
input_path = normalise_path(input_path)

first = True
for producer, ds_path, sibling_yaml_path in files_in_path(input_path):
Expand Down
6 changes: 4 additions & 2 deletions eodatasets3/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
from urllib.parse import urljoin, urlparse

import click
from datacube.utils.uris import normalise_path


class PathPath(click.Path):
"""A Click path argument that returns a pathlib Path, not a string"""
"""
A Click argument that returns a normalised (absolute) pathlib Path"""

def convert(self, value, param, ctx):
return Path(super().convert(value, param, ctx))
return Path(normalise_path(super().convert(value, param, ctx)))


def uri_resolve(base: Union[str, Path], path: Optional[str]) -> str:
Expand Down

0 comments on commit 0a2ba64

Please sign in to comment.