From 99195017851cc4d29487cf04473f841c20331f01 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Sat, 9 Nov 2024 10:07:00 -0700 Subject: [PATCH] fix: links on items --- src/heystac/__init__.py | 22 ++++++---------------- src/heystac/config.py | 6 +++--- stac | 2 +- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/heystac/__init__.py b/src/heystac/__init__.py index 3553c6a..218b883 100644 --- a/src/heystac/__init__.py +++ b/src/heystac/__init__.py @@ -1,5 +1,3 @@ -import sys - import click from .config import Config @@ -21,24 +19,16 @@ def bootstrap() -> None: @click.command() -@click.argument("id", default=None) -@click.option("--all", is_flag=True, help="Crawl every catalog") -def crawl(id: str | None, all: bool) -> None: +@click.argument("id") +def crawl(id: str) -> None: """Crawl a STAC API. - We don't crawl every API because that'd be expensive. + If id == "all" then we'll crawl all the catalogs — this could take a while. """ config = Config() - if id is None: - if all: - for id in config.catalogs.keys(): - config.crawl(id) - else: - print( - "To crawl every catalog, pass the --all flag", - file=sys.stderr, - ) - sys.exit(1) + if id == "all": + for id in config.catalogs.keys(): + config.crawl(id) else: config.crawl(id) diff --git a/src/heystac/config.py b/src/heystac/config.py index 6502985..f4f8e5f 100644 --- a/src/heystac/config.py +++ b/src/heystac/config.py @@ -106,7 +106,7 @@ def crawl(self, id: str) -> None: catalog.links.append(Link(href="../catalog.json", rel="root")) catalog.links.append(Link(href="../catalog.json", rel="parent")) - progress_bar = tqdm.tqdm(total=len(child_links) * 2) + progress_bar = tqdm.tqdm(total=len(child_links) * 2, desc=id) if (self.stac_path / id).exists(): shutil.rmtree(self.stac_path / id) for link in child_links: @@ -131,8 +131,8 @@ def crawl(self, id: str) -> None: for item in items.features: item.remove_structural_links() child.links.append(Link(href=f"./{item.id}.json", rel="item")) - item.links.append(Link(href="../collection.json", rel="parent")) - item.links.append(Link(href="../collection.json", rel="collection")) + item.links.append(Link(href="./collection.json", rel="parent")) + item.links.append(Link(href="./collection.json", rel="collection")) item.links.append(Link(href="../../../catalog.json", rel="root")) self.write_stac(item, f"{id}/{child.id}/{item.id}.json") self.write_stac(child, f"{id}/{child.id}/collection.json") diff --git a/stac b/stac index 5b7ee8f..13b7353 160000 --- a/stac +++ b/stac @@ -1 +1 @@ -Subproject commit 5b7ee8f15ecbbfe7bf9cc2a98a322a18bf2c51ef +Subproject commit 13b73532b93be0b4e152fb89e94c65a3558534fa