stac-validator 3.9.1__tar.gz → 3.9.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: stac_validator
3
- Version: 3.9.1
3
+ Version: 3.9.3
4
4
  Summary: A package to validate STAC files
5
5
  Home-page: https://github.com/stac-utils/stac-validator
6
6
  Author: James Banting, Jonathan Healy
@@ -26,7 +26,7 @@ License-File: LICENSE
26
26
  <img src="https://raw.githubusercontent.com/stac-utils/stac-validator/main/assets/stac-validator.png" width=560>
27
27
  </p>
28
28
 
29
- [![Downloads](https://static.pepy.tech/badge/stac-validator?color=blue)](https://pepy.tech/project/stac-validator)
29
+ [![PyPI Downloads](https://static.pepy.tech/badge/stac-validator/month)](https://pepy.tech/projects/stac-validator)
30
30
  [![GitHub contributors](https://img.shields.io/github/contributors/stac-utils/stac-validator?color=blue)](https://github.com/stac-utils/stac-validator/graphs/contributors)
31
31
  [![GitHub stars](https://img.shields.io/github/stars/stac-utils/stac-validator.svg?color=blue)](https://github.com/stac-utils/stac-validator/stargazers)
32
32
  [![GitHub forks](https://img.shields.io/github/forks/stac-utils/stac-validator.svg?color=blue)](https://github.com/stac-utils/stac-validator/network/members)
@@ -6,7 +6,7 @@
6
6
  <img src="https://raw.githubusercontent.com/stac-utils/stac-validator/main/assets/stac-validator.png" width=560>
7
7
  </p>
8
8
 
9
- [![Downloads](https://static.pepy.tech/badge/stac-validator?color=blue)](https://pepy.tech/project/stac-validator)
9
+ [![PyPI Downloads](https://static.pepy.tech/badge/stac-validator/month)](https://pepy.tech/projects/stac-validator)
10
10
  [![GitHub contributors](https://img.shields.io/github/contributors/stac-utils/stac-validator?color=blue)](https://github.com/stac-utils/stac-validator/graphs/contributors)
11
11
  [![GitHub stars](https://img.shields.io/github/stars/stac-utils/stac-validator.svg?color=blue)](https://github.com/stac-utils/stac-validator/stargazers)
12
12
  [![GitHub forks](https://img.shields.io/github/forks/stac-utils/stac-validator.svg?color=blue)](https://github.com/stac-utils/stac-validator/network/members)
@@ -2,7 +2,7 @@
2
2
 
3
3
  from setuptools import setup
4
4
 
5
- __version__ = "3.9.1"
5
+ __version__ = "3.9.3"
6
6
 
7
7
  with open("README.md", "r") as fh:
8
8
  long_description = fh.read()
@@ -618,12 +618,32 @@ class StacValidate:
618
618
  if link["rel"] in ("child", "item"):
619
619
  address = link["href"]
620
620
  if not is_valid_url(address):
621
- path_parts = str(base_url).split("/")
622
- path_parts.pop(-1)
623
- root = path_parts[0]
624
- for i in range(1, len(path_parts)):
625
- root = f"{root}/{path_parts[i]}"
626
- self.stac_file = f"{root}/{address}"
621
+ if is_valid_url(str(base_url)):
622
+ # If base is a URL, handle URL joining
623
+ from urllib.parse import urljoin
624
+
625
+ self.stac_file = urljoin(
626
+ (
627
+ str(base_url) + "/"
628
+ if not str(base_url).endswith("/")
629
+ else str(base_url)
630
+ ),
631
+ address,
632
+ )
633
+ else:
634
+ # Handle local file paths
635
+ current_dir = os.path.dirname(
636
+ os.path.abspath(str(base_url))
637
+ )
638
+ self.stac_file = os.path.normpath(
639
+ os.path.join(current_dir, address)
640
+ )
641
+ # Convert to relative path for cleaner output if it's under the current working directory
642
+ try:
643
+ self.stac_file = os.path.relpath(self.stac_file)
644
+ except ValueError:
645
+ # If paths are on different drives (Windows) or other relpath issues, use the absolute path
646
+ pass
627
647
  else:
628
648
  self.stac_file = address
629
649
 
@@ -681,10 +701,22 @@ class StacValidate:
681
701
  Args:
682
702
  item_collection (dict): The dictionary representation of the item collection.
683
703
  """
704
+ # Store the original stac_file to restore it later
705
+ original_stac_file = self.stac_file
706
+
684
707
  for item in item_collection["features"]:
708
+ # Update the path to include the item ID for better traceability
709
+ if isinstance(original_stac_file, str) and "id" in item:
710
+ # Remove any query string from the URL before appending the item ID
711
+ base_url = original_stac_file.split("?")[0]
712
+ self.stac_file = f"{base_url}/{item['id']}"
713
+
685
714
  self.schema = ""
686
715
  self.validate_dict(item)
687
716
 
717
+ # Restore the original stac_file
718
+ self.stac_file = original_stac_file
719
+
688
720
  def validate_collections(self) -> None:
689
721
  """
690
722
  Validate STAC Collections from a /collections endpoint.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: stac-validator
3
- Version: 3.9.1
3
+ Version: 3.9.3
4
4
  Summary: A package to validate STAC files
5
5
  Home-page: https://github.com/stac-utils/stac-validator
6
6
  Author: James Banting, Jonathan Healy
@@ -26,7 +26,7 @@ License-File: LICENSE
26
26
  <img src="https://raw.githubusercontent.com/stac-utils/stac-validator/main/assets/stac-validator.png" width=560>
27
27
  </p>
28
28
 
29
- [![Downloads](https://static.pepy.tech/badge/stac-validator?color=blue)](https://pepy.tech/project/stac-validator)
29
+ [![PyPI Downloads](https://static.pepy.tech/badge/stac-validator/month)](https://pepy.tech/projects/stac-validator)
30
30
  [![GitHub contributors](https://img.shields.io/github/contributors/stac-utils/stac-validator?color=blue)](https://github.com/stac-utils/stac-validator/graphs/contributors)
31
31
  [![GitHub stars](https://img.shields.io/github/stars/stac-utils/stac-validator.svg?color=blue)](https://github.com/stac-utils/stac-validator/stargazers)
32
32
  [![GitHub forks](https://img.shields.io/github/forks/stac-utils/stac-validator.svg?color=blue)](https://github.com/stac-utils/stac-validator/network/members)
File without changes
File without changes