[Git][debian-gis-team/stac-check][master] 8 commits: New upstream version 1.5.0+ds

Antonio Valentino (@antonio.valentino) gitlab at salsa.debian.org
Tue Jan 21 06:59:39 GMT 2025



Antonio Valentino pushed to branch master at Debian GIS Project / stac-check


Commits:
6313c4bd by Antonio Valentino at 2025-01-21T06:28:32+00:00
New upstream version 1.5.0+ds
- - - - -
3ab976b6 by Antonio Valentino at 2025-01-21T06:28:33+00:00
Update upstream source from tag 'upstream/1.5.0+ds'

Update to upstream version '1.5.0+ds'
with Debian dir 6ffabfed976d35709766ec579a08b2cfcb2a25c4
- - - - -
35e0c1cc by Antonio Valentino at 2025-01-21T06:29:18+00:00
New upstream release

- - - - -
22914a68 by Antonio Valentino at 2025-01-21T06:32:31+00:00
Add dependency on python3-requests-mock

- - - - -
696305d7 by Antonio Valentino at 2025-01-21T06:33:34+00:00
Update dates in d/copyright

- - - - -
41236c31 by Antonio Valentino at 2025-01-21T06:45:30+00:00
Refresh patches

- - - - -
646aa7f1 by Antonio Valentino at 2025-01-21T06:56:23+00:00
Skip tests requiring access to the internet

- - - - -
71914990 by Antonio Valentino at 2025-01-21T06:56:24+00:00
Set distribution to unstable

- - - - -


19 changed files:

- CHANGELOG.md
- README.md
- debian/changelog
- debian/control
- debian/copyright
- debian/patches/0001-Fix-privacy-breachs.patch
- − debian/patches/0002-No-pkg-resources.patch
- − debian/patches/0003-Fix-syntax-warning.patch
- debian/patches/series
- debian/rules
- docs/api.rst
- docs/cli.rst
- docs/conf.py
- docs/index.rst
- setup.py
- stac_check/cli.py
- stac_check/lint.py
- stac_check/logo.py
- tests/test_lint.py


Changes:

=====================================
CHANGELOG.md
=====================================
@@ -6,6 +6,25 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
 
 ## Unreleased
 
+### Changed
+
+## [v1.5.0] - 2025-01-17
+
+### Added
+
+- Allow to provide HTTP headers ([#114](https://github.com/stac-utils/stac-check/pull/114))
+- Configure whether to open URLs when validating assets ([#114](https://github.com/stac-utils/stac-check/pull/114))
+
+### Changed
+
+- No longer use the deprecated pkg-resources package.
+  It has been replaced with importlib from the Python standard library
+  ([#112](https://github.com/stac-utils/stac-check/pull/112))
+
+### Updated
+
+- Updated stac-validator to v3.5.0 and other dependecies as well ([#116](https://github.com/stac-utils/stac-check/pull/116))
+
 ## [v1.4.0] - 2024-10-09
 
 ### Added
@@ -148,7 +167,8 @@ The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/)
 - Validation from stac-validator 2.3.0
 - Links and assets validation checks
 
-[Unreleased]: https://github.com/stac-utils/stac-check/compare/v1.4.0...main
+[Unreleased]: https://github.com/stac-utils/stac-check/compare/v1.5.0...main
+[v1.5.0]: https://github.com/stac-utils/stac-check/compare/v1.4.0...v1.5.0
 [v1.4.0]: https://github.com/stac-utils/stac-check/compare/v1.3.3...v1.4.0
 [v1.3.3]: https://github.com/stac-utils/stac-check/compare/v1.3.2...v1.3.3
 [v1.3.2]: https://github.com/stac-utils/stac-check/compare/v1.3.1...v1.3.2


=====================================
README.md
=====================================
@@ -1,14 +1,19 @@
 # stac-check
+
 ## A linting and validation tool for STAC assets
 
 The intent of this project is to provide a validation tool that also follows the official [STAC Best Practices document](https://github.com/radiantearth/stac-spec/blob/master/best-practices.md)
 
 ---
+
 ### Documentation
+
 [stac-check.readthedocs.io](https://stac-check.readthedocs.io/en/latest/)
 
 ---
+
 ### Install
+
 `$ pip install stac-check`
 
 or for local development
@@ -16,7 +21,9 @@ or for local development
 `$ pip install -e '.[dev]'`
 
 ---
+
 ### CLI Usage
+
 ```
 Usage: stac-check [OPTIONS] FILE
 
@@ -28,16 +35,24 @@ Options:
                            argument to get full recursion. Ignored if
                            `recursive == False`.
   -r, --recursive          Recursively validate all related stac objects.
+  --no-assets-urls         Disables the opening of href links when validating assets
+                           (enabled by default).
+  --header KEY VALUE       HTTP header to include in the requests. Can be used
+                           multiple times.
   --help                   Show this message and exit.               Show this message and exit.
 ```
+
 ---
+
 ### Docker
 
 ```
 $ make build
 $ make shell
 ```
+
 ---
+
 ### Lint JSON
 
 ```
@@ -48,21 +63,24 @@ linter = Linter('<json_path>')
 for k, v in linter.create_best_practices_dict().items():
     print(k, ":", v)
 ```
+
 ---
+
 ### CLI Examples
 
-``` stac-check https://raw.githubusercontent.com/stac-utils/pystac/main/tests/data-files/examples/0.9.0/collection-spec/examples/landsat-collection.json --recursive ```
+`stac-check https://raw.githubusercontent.com/stac-utils/pystac/main/tests/data-files/examples/0.9.0/collection-spec/examples/landsat-collection.json --recursive`
+
 ```
  ____  ____  __    ___       ___  _  _  ____  ___  __ _
 / ___)(_  _)/ _\  / __)___  / __)/ )( \(  __)/ __)(  / )
 \___ \  )( /    \( (__(___)( (__ ) __ ( ) _)( (__  )  (
 (____/ (__)\_/\_/ \___)     \___)\_)(_/(____)\___)(__\_)
 
-stac-check: STAC spec validaton and linting tool
+stac-check: STAC spec validation and linting tool
 
-Please upgrade from version 0.9.0 to version 1.0.0!
+Please upgrade from version 0.9.0 to version 1.1.0!
 
-Validator: stac-validator 3.1.0
+Validator: stac-validator 3.5.0
 
 
 Recursive: Validate all assets in a collection or catalog
@@ -96,13 +114,13 @@ Error Message: Expecting value: line 1 column 1 (char 0)
 -------------------------
 ```
 
-``` stac-check sample_files/0.9.0/landsat8-sample.json```
+` stac-check sample_files/0.9.0/landsat8-sample.json`
 
-<pre><b>stac-check: STAC spec validaton and linting tool</b>
+<pre><b>stac-check: STAC spec validation and linting tool</b>
 
-Please upgrade from version 0.9.0 to version 1.0.0!
+Please upgrade from version 0.9.0 to version 1.1.0!
 
-Validator: stac-validator 2.3.0
+Validator: stac-validator 3.5.0
 
 Valid ITEM: True
 
@@ -124,13 +142,14 @@ STAC Best Practices:
 This object has 4 links
 </pre>
 
-``` stac-check sample_files/1.0.0/core-item.json --assets```
+` stac-check sample_files/1.0.0/core-item.json --assets`
+
 <pre>
-<b>stac-check: STAC spec validaton and linting tool</b>
+<b>stac-check: STAC spec validation and linting tool</b>
 
-Thanks for using STAC version 1.0.0!
+Please upgrade from version 1.0.0 to version 1.1.0!
 
-Validator: stac-validator 2.3.0
+Validator: stac-validator 3.5.0
 
 Valid ITEM: True
 
@@ -157,15 +176,14 @@ ASSET request errors:
 This object has 4 links
 </pre>
 
+` stac-check sample_files/1.0.0/core-item-bad-links.json --links --assets`
 
-
-``` stac-check sample_files/1.0.0/core-item-bad-links.json --links --assets```
 <pre>
-<b>stac-check: STAC spec validaton and linting tool</b>
+<b>stac-check: STAC spec validation and linting tool</b>
 
-Thanks for using STAC version 1.0.0!
+Please upgrade from version 1.0.0 to version 1.1.0!
 
-Validator: stac-validator 2.3.0
+Validator: stac-validator 3.5.0
 
 Valid ITEM: True
 
@@ -201,13 +219,14 @@ LINK request errors:
 This object has 4 links
 </pre>
 
-``` stac-check sample_files/0.9.0/bad-item.json```
+` stac-check sample_files/0.9.0/bad-item.json`
+
 <pre>
-<b>stac-check: STAC spec validaton and linting tool</b>
+<b>stac-check: STAC spec validation and linting tool</b>
 
-Please upgrade from version 0.9.0 to version 1.0.0!
+Please upgrade from version 0.9.0 to version 1.1.0!
 
-Validator: stac-validator 2.3.0
+Validator: stac-validator 3.5.0
 
 Valid : False
 
@@ -224,6 +243,34 @@ Validation error message:
 
 This object has 5 links
 </pre>
+
+` stac-check https://stac-catalog.eu/collections/sentinel-s2-l2a/items/item1 --assets --no-assets-urls --header x-api-key $MY_API_KEY --header foo bar`
+
+<pre>
+<b>stac-check: STAC spec validation and linting tool</b>
+
+Please upgrade from version 1.0.0 to version 1.1.0!
+
+Validator: stac-validator 3.5.0
+
+Valid ITEM: True
+
+Schemas validated: 
+    https://stac-extensions.github.io/timestamps/v1.1.0/schema.json
+    https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json
+
+STAC Best Practices: 
+    A STAC collection should contain a summaries field
+    It is recommended to store information like eo:bands in summaries
+
+
+No ASSET format errors!
+
+This object has 4 links
+</pre>
+
 ---
+
 ### Create local docs in the /docs folder
-`$ pdoc --html --output-dir pdoc stac_check --force`
+
+`$ pdoc --output-dir pdoc ./stac_check`


=====================================
debian/changelog
=====================================
@@ -1,3 +1,18 @@
+stac-check (1.5.0+ds-1) unstable; urgency=medium
+
+  * New upstream release.
+  * debian/control:
+    - Add dependency on python3-requests-mock.
+  * Update dates in d/copyright.
+  * debian/patches:
+    - Drop 0002-No-pkg-resources.patch and
+      0003-Fix-syntax-warning.patch, applied upstream.
+    - Refresh remaining patches.
+  * debian/rules:
+    - Skip tests requiring access to the internet.
+
+ -- Antonio Valentino <antonio.valentino at tiscali.it>  Tue, 21 Jan 2025 06:45:35 +0000
+
 stac-check (1.4.0+ds-2) unstable; urgency=medium
 
   * debian/patches:


=====================================
debian/control
=====================================
@@ -14,6 +14,7 @@ Build-Depends: debhelper-compat (= 13),
                python3-jsonschema,
                python3-pytest <!nocheck>,
                python3-requests,
+               python3-requests-mock <!nocheck>,
                python3-setuptools,
                python3-sphinx <!nodoc>,
                python3-stac-validator,


=====================================
debian/copyright
=====================================
@@ -11,7 +11,7 @@ Copyright: 2021, Jonathan Healy <jonathan.d.healy at gmail.com>
 License: Expat
 
 Files: debian/*
-Copyright: 2024, Antonio Valentino <antonio.valentino at tiscali.it>
+Copyright: 2025, Antonio Valentino <antonio.valentino at tiscali.it>
 License: Expat
 
 License: Expat


=====================================
debian/patches/0001-Fix-privacy-breachs.patch
=====================================
@@ -9,7 +9,7 @@ Forwarded: not-needed
  2 files changed, 6 insertions(+), 10 deletions(-)
 
 diff --git a/docs/api.rst b/docs/api.rst
-index 40a7680..2097129 100644
+index 9d8d42e..04a61b5 100644
 --- a/docs/api.rst
 +++ b/docs/api.rst
 @@ -10,13 +10,11 @@ API Reference
@@ -28,7 +28,7 @@ index 40a7680..2097129 100644
          <script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
          </head>
          <body>
-@@ -2292,4 +2290,4 @@ API Reference
+@@ -2293,4 +2291,4 @@ API Reference
          <p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.9.2</a>.</p>
          </footer>
          </body>
@@ -36,7 +36,7 @@ index 40a7680..2097129 100644
 \ No newline at end of file
 +    </embed>
 diff --git a/docs/cli.rst b/docs/cli.rst
-index 1e335c4..15ea456 100644
+index 418d2f2..6881448 100644
 --- a/docs/cli.rst
 +++ b/docs/cli.rst
 @@ -10,13 +10,11 @@ CLI Reference


=====================================
debian/patches/0002-No-pkg-resources.patch deleted
=====================================
@@ -1,175 +0,0 @@
-From: Antonio Valentino <antonio.valentino at tiscali.it>
-Date: Mon, 14 Oct 2024 06:45:38 +0000
-Subject: No pkg-resources
-
-FOrwarded: https://github.com/stac-utils/stac-check/pull/112
----
- docs/api.rst       | 15 ++++++++-------
- docs/cli.rst       |  4 ++--
- setup.py           |  2 +-
- stac_check/cli.py  |  4 ++--
- stac_check/lint.py |  7 ++++---
- 5 files changed, 17 insertions(+), 15 deletions(-)
-
-diff --git a/docs/api.rst b/docs/api.rst
-index 2097129..4c21b82 100644
---- a/docs/api.rst
-+++ b/docs/api.rst
-@@ -28,7 +28,7 @@ API Reference
-         <summary>
-         <span>Expand source code</span>
-         </summary>
--        <pre><code class="python">import pkg_resources
-+        <pre><code class="python">
-         from stac_validator.validate import StacValidate
-         from stac_validator.utilities import is_valid_url
-         import json
-@@ -38,7 +38,8 @@ API Reference
-         import requests
-         from typing import Optional, Union, Dict, Any, List
-         from dotenv import load_dotenv
--        import pkg_resources
-+        import importlib.metadata
-+	import importlib.resources
- 
-         load_dotenv()
- 
-@@ -160,7 +161,7 @@ API Reference
-                 self.config = self.parse_config(self.config_file)
-                 self.asset_type = self.message["asset_type"] if "asset_type" in self.message else ""
-                 self.version = self.message["version"] if "version" in self.message else ""
--                self.validator_version = pkg_resources.require("stac-validator")[0].version
-+                self.validator_version = importlib.metadata.distribution("stac-validator").version
-                 self.validate_all = self.recursive_validation(self.item)
-                 self.valid_stac = self.message["valid_stac"]
-                 self.error_type = self.check_error_type()
-@@ -203,7 +204,7 @@ API Reference
-                     with open(default_config_file) as f:
-                         default_config = yaml.load(f, Loader=yaml.FullLoader)
-                 else:
--                    with pkg_resources.resource_stream(__name__, "stac-check.config.yml") as f:
-+                    with importlib.resources.open_text(__name__, "stac-check.config.yml") as f:
-                         default_config = yaml.load(f, Loader=yaml.FullLoader)
-                 if config_file:
-                     with open(config_file) as f:
-@@ -864,7 +865,7 @@ API Reference
-                 self.config = self.parse_config(self.config_file)
-                 self.asset_type = self.message["asset_type"] if "asset_type" in self.message else ""
-                 self.version = self.message["version"] if "version" in self.message else ""
--                self.validator_version = pkg_resources.require("stac-validator")[0].version
-+                self.validator_version = importlib.metadata.distribution("stac-validator")[0].version
-                 self.validate_all = self.recursive_validation(self.item)
-                 self.valid_stac = self.message["valid_stac"]
-                 self.error_type = self.check_error_type()
-@@ -907,7 +908,7 @@ API Reference
-                     with open(default_config_file) as f:
-                         default_config = yaml.load(f, Loader=yaml.FullLoader)
-                 else:
--                    with pkg_resources.resource_stream(__name__, "stac-check.config.yml") as f:
-+                    with importlib.resources.open_text(__name__, "stac-check.config.yml") as f:
-                         default_config = yaml.load(f, Loader=yaml.FullLoader)
-                 if config_file:
-                     with open(config_file) as f:
-@@ -1414,7 +1415,7 @@ API Reference
-                 with open(default_config_file) as f:
-                     default_config = yaml.load(f, Loader=yaml.FullLoader)
-             else:
--                with pkg_resources.resource_stream(__name__, "stac-check.config.yml") as f:
-+                with importlib.resources.open_text(__name__, "stac-check.config.yml") as f:
-                     default_config = yaml.load(f, Loader=yaml.FullLoader)
-             if config_file:
-                 with open(config_file) as f:
-diff --git a/docs/cli.rst b/docs/cli.rst
-index 15ea456..ce1eef4 100644
---- a/docs/cli.rst
-+++ b/docs/cli.rst
-@@ -30,7 +30,7 @@ CLI Reference
-     </summary>
-     <pre><code class="python">import click
-     from .lint import Linter
--    import pkg_resources
-+    import importlib.matadata
- 
-     def link_asset_message(link_list:list, type: str, format: str) -> None:
-         """Prints a list of links or assets and any errors associated with them.
-@@ -203,7 +203,7 @@ CLI Reference
-     )
-     @click.command()
-     @click.argument('file')
--    @click.version_option(version=pkg_resources.require("stac-check")[0].version)
-+    @click.version_option(version=importlib.metadata.distribution("stac-check").version)
-     def main(file, recursive, max_depth, assets, links):
-         linter = Linter(file, assets=assets, links=links, recursive=recursive, max_depth=max_depth)
-         intro_message(linter)
-diff --git a/setup.py b/setup.py
-index a830685..c531b39 100644
---- a/setup.py
-+++ b/setup.py
-@@ -15,6 +15,7 @@ setup(
-     url="https://github.com/stac-utils/stac-check",
-     packages=find_packages(exclude=("tests",)),
-     include_package_data=True,
-+    setup_requires=["setuptools"],
-     install_requires=[
-         "click>=8.0.0",
-         "requests>=2.19.1",
-@@ -22,7 +23,6 @@ setup(
-         "stac-validator>=3.4.0",
-         "PyYAML",
-         "python-dotenv",
--        "setuptools",
-     ],
-     extras_require={
-         "dev": [
-diff --git a/stac_check/cli.py b/stac_check/cli.py
-index 491ceee..89e9ab6 100644
---- a/stac_check/cli.py
-+++ b/stac_check/cli.py
-@@ -1,5 +1,5 @@
- import click
--import pkg_resources
-+import importlib.metadata
- 
- from .lint import Linter
- from .logo import logo
-@@ -177,7 +177,7 @@ def cli_message(linter: Linter) -> None:
- )
- @click.command()
- @click.argument("file")
-- at click.version_option(version=pkg_resources.require("stac-check")[0].version)
-+ at click.version_option(version=importlib.metadata.distribution("stac-check").version)
- def main(file, recursive, max_depth, assets, links):
-     linter = Linter(
-         file, assets=assets, links=links, recursive=recursive, max_depth=max_depth
-diff --git a/stac_check/lint.py b/stac_check/lint.py
-index 0db65b0..ab63095 100644
---- a/stac_check/lint.py
-+++ b/stac_check/lint.py
-@@ -3,7 +3,8 @@ import os
- from dataclasses import dataclass
- from typing import Any, Dict, List, Optional, Union
- 
--import pkg_resources
-+import importlib.metadata
-+import importlib.resources
- import requests
- import yaml
- from dotenv import load_dotenv
-@@ -134,7 +135,7 @@ class Linter:
-             self.message["asset_type"] if "asset_type" in self.message else ""
-         )
-         self.version = self.message["version"] if "version" in self.message else ""
--        self.validator_version = pkg_resources.require("stac-validator")[0].version
-+        self.validator_version = importlib.metadata.distribution("stac-validator").version
-         self.validate_all = self.recursive_validation(self.item)
-         self.valid_stac = self.message["valid_stac"]
-         self.error_type = self.check_error_type()
-@@ -185,7 +186,7 @@ class Linter:
-             with open(default_config_file) as f:
-                 default_config = yaml.load(f, Loader=yaml.FullLoader)
-         else:
--            with pkg_resources.resource_stream(__name__, "stac-check.config.yml") as f:
-+            with importlib.resources.open_text(__name__, "stac-check.config.yml") as f:
-                 default_config = yaml.load(f, Loader=yaml.FullLoader)
-         if config_file:
-             with open(config_file) as f:


=====================================
debian/patches/0003-Fix-syntax-warning.patch deleted
=====================================
@@ -1,21 +0,0 @@
-From: Antonio Valentino <antonio.valentino at tiscali.it>
-Date: Sat, 9 Nov 2024 11:35:44 +0000
-Subject: Fix syntax warning
-
-Forwarded: https://github.com/stac-utils/stac-check/pull/113
----
- stac_check/logo.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/stac_check/logo.py b/stac_check/logo.py
-index 0ea5b17..a6f5d0d 100644
---- a/stac_check/logo.py
-+++ b/stac_check/logo.py
-@@ -1,6 +1,6 @@
- # flake8: noqa
- 
--logo = """
-+logo = r"""
-  ____  ____  __    ___       ___  _  _  ____  ___  __ _ 
- / ___)(_  _)/ _\  / __)___  / __)/ )( \(  __)/ __)(  / )
- \___ \  )( /    \( (__(___)( (__ ) __ ( ) _)( (__  )  ( 


=====================================
debian/patches/series
=====================================
@@ -1,3 +1 @@
 0001-Fix-privacy-breachs.patch
-0002-No-pkg-resources.patch
-0003-Fix-syntax-warning.patch


=====================================
debian/rules
=====================================
@@ -1,22 +1,25 @@
 #!/usr/bin/make -f
 
 export PYBUILD_NAME=stac_check
-export PYBUILD_TEST_ARGS=-v -k "not test_linter_config_file \
-                            and not test_linter_bad_assets \
-                            and not test_linter_bad_links \
-                            and not test_linter_bad_links_assets \
-                            and not test_linter_collection \
-                            and not test_linter_collection_no_summaries \
-                            and not test_linter_catalog \
-                            and not test_linter_collection_recursive \
-                            and not test_linter_recursive_max_depth_1 \
-                            and not test_linter_recursive_max_depth_4 \
-                            and not test_linter_item_id_not_matching_file_name \
-                            and not test_linter_collection_catalog_id \
-                            and not test_linter_item_id_format_best_practices \
-                            and not test_title_field \
-                            and not test_lint_dict_collection \
-                            and not test_lint_dict_item"
+export PYBUILD_TEST_ARGS=-v \
+-k "not test_linter_config_file \
+and not test_linter_bad_assets \
+and not test_linter_bad_links \
+and not test_linter_bad_links_assets \
+and not test_linter_collection \
+and not test_linter_collection_no_summaries \
+and not test_linter_catalog \
+and not test_linter_collection_recursive \
+and not test_linter_recursive_max_depth_1 \
+and not test_linter_recursive_max_depth_4 \
+and not test_linter_item_id_not_matching_file_name \
+and not test_linter_collection_catalog_id \
+and not test_linter_item_id_format_best_practices \
+and not test_title_field \
+and not test_lint_dict_collection \
+and not test_lint_dict_item \
+and not test_lint_header \
+and not test_lint_assets_no_links"
 export PYBUILD_BEFORE_TEST=cp -r sample_files/ {build_dir}
 export PYBUILD_AFTER_TEST=rm -rf {build_dir}/sample_files/
 


=====================================
docs/api.rst
=====================================
@@ -30,7 +30,7 @@ API Reference
         <summary>
         <span>Expand source code</span>
         </summary>
-        <pre><code class="python">import pkg_resources
+        <pre><code class="python">
         from stac_validator.validate import StacValidate
         from stac_validator.utilities import is_valid_url
         import json
@@ -40,7 +40,8 @@ API Reference
         import requests
         from typing import Optional, Union, Dict, Any, List
         from dotenv import load_dotenv
-        import pkg_resources
+        import importlib.metadata
+	import importlib.resources
 
         load_dotenv()
 
@@ -162,7 +163,7 @@ API Reference
                 self.config = self.parse_config(self.config_file)
                 self.asset_type = self.message["asset_type"] if "asset_type" in self.message else ""
                 self.version = self.message["version"] if "version" in self.message else ""
-                self.validator_version = pkg_resources.require("stac-validator")[0].version
+                self.validator_version = importlib.metadata.distribution("stac-validator").version
                 self.validate_all = self.recursive_validation(self.item)
                 self.valid_stac = self.message["valid_stac"]
                 self.error_type = self.check_error_type()
@@ -205,7 +206,7 @@ API Reference
                     with open(default_config_file) as f:
                         default_config = yaml.load(f, Loader=yaml.FullLoader)
                 else:
-                    with pkg_resources.resource_stream(__name__, "stac-check.config.yml") as f:
+                    with importlib.resources.open_text(__name__, "stac-check.config.yml") as f:
                         default_config = yaml.load(f, Loader=yaml.FullLoader)
                 if config_file:
                     with open(config_file) as f:
@@ -866,7 +867,7 @@ API Reference
                 self.config = self.parse_config(self.config_file)
                 self.asset_type = self.message["asset_type"] if "asset_type" in self.message else ""
                 self.version = self.message["version"] if "version" in self.message else ""
-                self.validator_version = pkg_resources.require("stac-validator")[0].version
+                self.validator_version = importlib.metadata.distribution("stac-validator").version
                 self.validate_all = self.recursive_validation(self.item)
                 self.valid_stac = self.message["valid_stac"]
                 self.error_type = self.check_error_type()
@@ -909,7 +910,7 @@ API Reference
                     with open(default_config_file) as f:
                         default_config = yaml.load(f, Loader=yaml.FullLoader)
                 else:
-                    with pkg_resources.resource_stream(__name__, "stac-check.config.yml") as f:
+                    with importlib.resources.open_text(__name__, "stac-check.config.yml") as f:
                         default_config = yaml.load(f, Loader=yaml.FullLoader)
                 if config_file:
                     with open(config_file) as f:
@@ -1416,7 +1417,7 @@ API Reference
                 with open(default_config_file) as f:
                     default_config = yaml.load(f, Loader=yaml.FullLoader)
             else:
-                with pkg_resources.resource_stream(__name__, "stac-check.config.yml") as f:
+                with importlib.resources.open_text(__name__, "stac-check.config.yml") as f:
                     default_config = yaml.load(f, Loader=yaml.FullLoader)
             if config_file:
                 with open(config_file) as f:


=====================================
docs/cli.rst
=====================================
@@ -32,7 +32,7 @@ CLI Reference
     </summary>
     <pre><code class="python">import click
     from .lint import Linter
-    import pkg_resources
+    import importlib.matadata
 
     def link_asset_message(link_list:list, type: str, format: str) -> None:
         """Prints a list of links or assets and any errors associated with them.
@@ -102,7 +102,7 @@ CLI Reference
     (____/ (__)\_/\_/ \___)     \___)\_)(_/(____)\___)(__\_)
         """)
 
-        click.secho("stac-check: STAC spec validaton and linting tool", bold=True)
+        click.secho("stac-check: STAC spec validation and linting tool", bold=True)
 
         click.secho()
 
@@ -205,7 +205,7 @@ CLI Reference
     )
     @click.command()
     @click.argument('file')
-    @click.version_option(version=pkg_resources.require("stac-check")[0].version)
+    @click.version_option(version=importlib.metadata.distribution("stac-check").version)
     def main(file, recursive, max_depth, assets, links):
         linter = Linter(file, assets=assets, links=links, recursive=recursive, max_depth=max_depth)
         intro_message(linter)
@@ -351,7 +351,7 @@ CLI Reference
     (____/ (__)\_/\_/ \___)     \___)\_)(_/(____)\___)(__\_)
         """)
 
-        click.secho("stac-check: STAC spec validaton and linting tool", bold=True)
+        click.secho("stac-check: STAC spec validation and linting tool", bold=True)
 
         click.secho()
 


=====================================
docs/conf.py
=====================================
@@ -10,7 +10,7 @@ from typing import List
 
 project = "stac-check"
 author = "Jonathan Healy"
-release = "1.3.1"
+release = "1.5.0"
 
 
 # -- General configuration ---------------------------------------------------


=====================================
docs/index.rst
=====================================
@@ -41,10 +41,14 @@ CLI Usage
       -l, --links              Validate links for format and response.
       -a, --assets             Validate assets for format and response.
       -m, --max-depth INTEGER  Maximum depth to traverse when recursing. Omit this
-                               argument to get full recursion. Ignored if
-                              `recursive == False`.
+                                 argument to get full recursion. Ignored if
+                                 `recursive == False`.
       -r, --recursive          Recursively validate all related stac objects.
-      --help                   Show this message and exit.
+      --no-assets-urls         Disables the opening of href links when validating assets
+                                 (enabled by default).
+      --header KEY VALUE       HTTP header to include in the requests. Can be used
+                                 multiple times.
+      --help                   Show this message and exit.               Show this message and exit.
 
 Examples
 ~~~~~~~~
@@ -91,7 +95,7 @@ STAC Versions supported
 
 ``stac-check`` supports the following STAC versions:
 
-``[0.8.0, 0.8.1, 0.9.0, 1.0.0-beta.1, 1.0.0-beta.2, 1.0.0-rc.1, 1.0.0-rc.2, 1.0.0-rc.3, 1.0.0-rc.4, 1.0.0]``
+``[0.8.0, 0.8.1, 0.9.0, 1.0.0-beta.1, 1.0.0-beta.2, 1.0.0-rc.1, 1.0.0-rc.2, 1.0.0-rc.3, 1.0.0-rc.4, 1.0.0, 1.1.0]``
 
 .. toctree::
    :maxdepth: 1


=====================================
setup.py
=====================================
@@ -3,7 +3,7 @@
 
 from setuptools import find_packages, setup
 
-__version__ = "1.4.0"
+__version__ = "1.5.0"
 
 with open("README.md", "r") as fh:
     long_description = fh.read()
@@ -15,18 +15,19 @@ setup(
     url="https://github.com/stac-utils/stac-check",
     packages=find_packages(exclude=("tests",)),
     include_package_data=True,
+    setup_requires=["setuptools"],
     install_requires=[
-        "click>=8.0.0",
-        "requests>=2.19.1",
-        "jsonschema>=3.1.2",
-        "stac-validator>=3.4.0",
+        "requests>=2.32.3",
+        "jsonschema>=4.23.0",
+        "click>=8.1.8",
+        "stac-validator>=3.5.0",
         "PyYAML",
         "python-dotenv",
-        "setuptools",
     ],
     extras_require={
         "dev": [
             "pytest",
+            "requests-mock",
             "types-setuptools",
         ],
     },


=====================================
stac_check/cli.py
=====================================
@@ -1,17 +1,21 @@
+import importlib.metadata
+
 import click
-import pkg_resources
 
 from .lint import Linter
 from .logo import logo
 
 
-def link_asset_message(link_list: list, type: str, format: str) -> None:
+def link_asset_message(
+    link_list: list, type: str, format: str, healthy_msg: bool
+) -> None:
     """Prints a list of links or assets and any errors associated with them.
 
     Args:
         link_list (list): A list of links or assets.
         type (str): The type of link or asset being processed.
         format (str): The format or request being used.
+        healthy_msg (bool): Whether to display "No TYPE errors!" or not
 
     Returns:
         None.
@@ -20,7 +24,7 @@ def link_asset_message(link_list: list, type: str, format: str) -> None:
         click.secho(f"{type.upper()} {format} errors: ", fg="red")
         for asset in link_list:
             click.secho(f"    {asset}")
-    else:
+    elif healthy_msg:
         click.secho(f"No {type.upper()} {format} errors!", fg="green")
 
 
@@ -38,7 +42,9 @@ def recursive_message(linter: Linter) -> None:
     click.secho(f"Max-depth = {linter.max_depth}")
     click.secho("-------------------------")
     for count, msg in enumerate(linter.validate_all):
-        click.secho(f"Asset {count+1} Validated: {msg['path']}", bg="white", fg="black")
+        click.secho(
+            f"Asset {count + 1} Validated: {msg['path']}", bg="white", fg="black"
+        )
         click.secho()
         if msg["valid_stac"] == True:
             recursive_linter = Linter(msg["path"], recursive=True)
@@ -70,11 +76,11 @@ def intro_message(linter: Linter) -> None:
     """
     click.secho(logo)
 
-    click.secho("stac-check: STAC spec validaton and linting tool", bold=True)
+    click.secho("stac-check: STAC spec validation and linting tool", bold=True)
 
     click.secho()
 
-    if linter.version == "1.0.0":
+    if linter.version == "1.1.0":
         click.secho(linter.set_update_message(), fg="green")
     else:
         click.secho(linter.set_update_message(), fg="red")
@@ -127,19 +133,21 @@ def cli_message(linter: Linter) -> None:
 
     if linter.invalid_asset_format is not None:
         click.secho()
-        link_asset_message(linter.invalid_asset_format, "asset", "format")
+        link_asset_message(linter.invalid_asset_format, "asset", "format", True)
 
     if linter.invalid_asset_request is not None:
         click.secho()
-        link_asset_message(linter.invalid_asset_request, "asset", "request")
+        link_asset_message(
+            linter.invalid_asset_request, "asset", "request", linter.assets_open_urls
+        )
 
     if linter.invalid_link_format is not None:
         click.secho()
-        link_asset_message(linter.invalid_link_format, "link", "format")
+        link_asset_message(linter.invalid_link_format, "link", "format", True)
 
     if linter.invalid_link_request is not None:
         click.secho()
-        link_asset_message(linter.invalid_link_request, "link", "request")
+        link_asset_message(linter.invalid_link_request, "link", "request", True)
 
     if linter.error_type != "":
         click.secho("Validation error type: ", fg="red")
@@ -175,12 +183,29 @@ def cli_message(linter: Linter) -> None:
 @click.option(
     "-l", "--links", is_flag=True, help="Validate links for format and response."
 )
+ at click.option(
+    "--no-assets-urls",
+    is_flag=True,
+    help="Disables the opening of href links when validating assets (enabled by default).",
+)
+ at click.option(
+    "--header",
+    type=(str, str),
+    multiple=True,
+    help="HTTP header to include in the requests. Can be used multiple times.",
+)
 @click.command()
 @click.argument("file")
- at click.version_option(version=pkg_resources.require("stac-check")[0].version)
-def main(file, recursive, max_depth, assets, links):
+ at click.version_option(version=importlib.metadata.distribution("stac-check").version)
+def main(file, recursive, max_depth, assets, links, no_assets_urls, header):
     linter = Linter(
-        file, assets=assets, links=links, recursive=recursive, max_depth=max_depth
+        file,
+        assets=assets,
+        links=links,
+        recursive=recursive,
+        max_depth=max_depth,
+        assets_open_urls=not no_assets_urls,
+        headers=dict(header),
     )
     intro_message(linter)
     if recursive > 0:


=====================================
stac_check/lint.py
=====================================
@@ -1,9 +1,10 @@
+import importlib.metadata
+import importlib.resources
 import json
 import os
-from dataclasses import dataclass
+from dataclasses import dataclass, field
 from typing import Any, Dict, List, Optional, Union
 
-import pkg_resources
 import requests
 import yaml
 from dotenv import load_dotenv
@@ -24,6 +25,8 @@ class Linter:
         links (bool, optional): A boolean value indicating whether to validate links. Defaults to False.
         recursive (bool, optional): A boolean value indicating whether to perform recursive validation. Defaults to False.
         max_depth (Optional[int], optional): An optional integer indicating the maximum depth to validate recursively. Defaults to None.
+        assets_open_urls (bool): Whether to open assets URLs when validating assets. Defaults to True.
+        headers (dict): HTTP headers to include in the requests.
 
     Attributes:
         data (dict): A dictionary representing the STAC JSON file.
@@ -125,6 +128,8 @@ class Linter:
     links: bool = False
     recursive: bool = False
     max_depth: Optional[int] = None
+    assets_open_urls: bool = True
+    headers: dict = field(default_factory=dict)
 
     def __post_init__(self):
         self.data = self.load_data(self.item)
@@ -134,7 +139,9 @@ class Linter:
             self.message["asset_type"] if "asset_type" in self.message else ""
         )
         self.version = self.message["version"] if "version" in self.message else ""
-        self.validator_version = pkg_resources.require("stac-validator")[0].version
+        self.validator_version = importlib.metadata.distribution(
+            "stac-validator"
+        ).version
         self.validate_all = self.recursive_validation(self.item)
         self.valid_stac = self.message["valid_stac"]
         self.error_type = self.check_error_type()
@@ -185,7 +192,9 @@ class Linter:
             with open(default_config_file) as f:
                 default_config = yaml.load(f, Loader=yaml.FullLoader)
         else:
-            with pkg_resources.resource_stream(__name__, "stac-check.config.yml") as f:
+            with importlib.resources.open_text(
+                "stac_check", "stac-check.config.yml"
+            ) as f:
                 default_config = yaml.load(f, Loader=yaml.FullLoader)
         if config_file:
             with open(config_file) as f:
@@ -231,7 +240,7 @@ class Linter:
 
         if isinstance(file, str):
             if is_valid_url(file):
-                resp = requests.get(file)
+                resp = requests.get(file, headers=self.headers)
                 data = resp.json()
             else:
                 with open(file) as json_file:
@@ -255,10 +264,18 @@ class Linter:
             ValueError: If `file` is not a valid file path or STAC dictionary.
         """
         if isinstance(file, str):
-            stac = StacValidate(file, links=self.links, assets=self.assets)
+            stac = StacValidate(
+                file,
+                links=self.links,
+                assets=self.assets,
+                assets_open_urls=self.assets_open_urls,
+                headers=self.headers,
+            )
             stac.run()
         elif isinstance(file, dict):
-            stac = StacValidate()
+            stac = StacValidate(
+                assets_open_urls=self.assets_open_urls, headers=self.headers
+            )
             stac.validate_dict(file)
         else:
             raise ValueError("Input must be a file path or STAC dictionary.")
@@ -279,10 +296,21 @@ class Linter:
         """
         if self.recursive:
             if isinstance(file, str):
-                stac = StacValidate(file, recursive=True, max_depth=self.max_depth)
+                stac = StacValidate(
+                    file,
+                    recursive=True,
+                    max_depth=self.max_depth,
+                    assets_open_urls=self.assets_open_urls,
+                    headers=self.headers,
+                )
                 stac.run()
             else:
-                stac = StacValidate(recursive=True, max_depth=self.max_depth)
+                stac = StacValidate(
+                    recursive=True,
+                    max_depth=self.max_depth,
+                    assets_open_urls=self.assets_open_urls,
+                    headers=self.headers,
+                )
                 stac.validate_dict(file)
             return stac.message
         else:
@@ -294,10 +322,10 @@ class Linter:
         Returns:
             A string containing a message for users to update their STAC version.
         """
-        if self.version != "1.0.0":
-            return f"Please upgrade from version {self.version} to version 1.0.0!"
+        if self.version != "1.1.0":
+            return f"Please upgrade from version {self.version} to version 1.1.0!"
         else:
-            return "Thanks for using STAC version 1.0.0!"
+            return "Thanks for using STAC version 1.1.0!"
 
     def check_links_assets(
         self, num_links: int, url_type: str, format_type: str


=====================================
stac_check/logo.py
=====================================
@@ -1,6 +1,6 @@
 # flake8: noqa
 
-logo = """
+logo = r"""
  ____  ____  __    ___       ___  _  _  ____  ___  __ _ 
 / ___)(_  _)/ _\  / __)___  / __)/ )( \(  __)/ __)(  / )
 \___ \  )( /    \( (__(___)( (__ ) __ ( ) _)( (__  )  ( 


=====================================
tests/test_lint.py
=====================================
@@ -1,4 +1,7 @@
+import json
+
 import pytest
+import requests_mock
 
 from stac_check.lint import Linter
 
@@ -498,3 +501,65 @@ def test_lint_dict_item():
     assert linter.create_best_practices_dict()["datetime_null"] == [
         "Please avoid setting the datetime field to null, many clients search on this field"
     ]
+
+
+def test_lint_header():
+    file = "sample_files/1.0.0/core-item.json"
+    url = "https://localhost/" + file
+
+    no_headers = {}
+    valid_headers = {"x-api-key": "a-valid-api-key"}
+
+    with requests_mock.Mocker(real_http=True) as mock, open(file) as json_data:
+        mock.get(url, request_headers=no_headers, status_code=403, json={})
+        mock.get(url, request_headers=valid_headers, json=json.load(json_data))
+
+        linter = Linter(url, assets=False, headers=valid_headers)
+        assert linter.message == {
+            "version": "1.0.0",
+            "path": "https://localhost/sample_files/1.0.0/core-item.json",
+            "schema": [
+                "https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json"
+            ],
+            "valid_stac": True,
+            "asset_type": "ITEM",
+            "validation_method": "default",
+        }
+
+        linter = Linter(url, assets=False, headers=no_headers)
+        assert linter.message == {
+            "version": "",
+            "path": "https://localhost/sample_files/1.0.0/core-item.json",
+            "schema": [""],
+            "valid_stac": False,
+            "error_type": "HTTPError",
+            "error_message": "403 Client Error: None for url: https://localhost/sample_files/1.0.0/core-item.json",
+        }
+
+
+def test_lint_assets_no_links():
+    file = "sample_files/1.0.0/core-item.json"
+    linter = Linter(file, assets=True, assets_open_urls=False)
+    assert linter.message == {
+        "version": "1.0.0",
+        "path": file,
+        "schema": [
+            "https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/item.json"
+        ],
+        "valid_stac": True,
+        "asset_type": "ITEM",
+        "validation_method": "default",
+        "assets_validated": {
+            "format_valid": [
+                "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2_analytic.tif",
+                "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2.jpg",
+                "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2.tif",
+                "https://storage.googleapis.com/open-cogs/stac-examples/20201211_223832_CS2_analytic_udm.tif",
+                "http://remotedata.io/catalog/20201211_223832_CS2/extended-metadata.json",
+                "http://cool-sat.com/catalog/20201211_223832_CS2/20201211_223832_CS2.EPH",
+            ],
+            "format_invalid": [],
+            "request_valid": [],
+            "request_invalid": [],
+        },
+    }



View it on GitLab: https://salsa.debian.org/debian-gis-team/stac-check/-/compare/2309162c48e6af910d9009299616f04a7427731a...71914990aa836423f9c4c091ceed09a5993d348c

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/stac-check/-/compare/2309162c48e6af910d9009299616f04a7427731a...71914990aa836423f9c4c091ceed09a5993d348c
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20250121/61dda9f7/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list