Skip to content

Commit 905b5c1

Browse files
authored
Merge pull request #184 from sparkgeo/stac_lint
Add linting option from stac-check
2 parents fcb905a + 8bb4b32 commit 905b5c1

File tree

6 files changed

+36
-20
lines changed

6 files changed

+36
-20
lines changed

.github/workflows/publish-to-pypi.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
--outdir dist/
3434
3535
- name: Publish distribution to PyPI
36-
if: startsWith(github.ref, 'refs/tags')
36+
# if: startsWith(github.ref, 'refs/tags')
3737
uses: pypa/[email protected]
3838
with:
3939
password: ${{ secrets.PYPI_API_TOKEN }}

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
The format is (loosely) based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [v2.4.0] - 2022-02-02
8+
### Added
9+
10+
- Linting option in cli to display stac-check generated information
711

812
## [v2.3.0] - 2021-08-31 - 2021-11-28
913
### Added

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ stac_validator --help
100100
Usage: stac_validator [OPTIONS] STAC_FILE
101101

102102
Options:
103+
--lint Use stac-check to lint stac object.
103104
--core Validate core stac object only without extensions.
104105
--extensions Validate extensions only.
105106
--links Additionally validate links. Only works with
@@ -111,6 +112,7 @@ Options:
111112
-r, --recursive INTEGER Recursively validate all related stac objects. A
112113
depth of -1 indicates full recursion.
113114
-v, --verbose Enables verbose output for recursive mode.
115+
--no_output Do not print output to console.
114116
--log_file TEXT Save full recursive output to log file (local
115117
filepath).
116118
--version Show the version and exit.

setup.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from setuptools import setup
44

5-
__version__ = "2.3.0"
5+
__version__ = "2.4.0"
66

77
with open("README.md", "r") as fh:
88
long_description = fh.read()
@@ -35,6 +35,7 @@
3535
"jsonschema>=3.2.0",
3636
"pystac[validation]==1.1.0",
3737
"click>=8.0.0",
38+
"stac-check==1.0.2",
3839
],
3940
packages=["stac_validator"],
4041
entry_points={

stac_validator/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.3.0"
1+
__version__ = "2.4.0"

stac_validator/stac_validator.py

+26-17
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
import sys
33

44
import click # type: ignore
5+
from stac_check.cli import cli_message as lint_message # type: ignore
6+
from stac_check.lint import Linter # type: ignore
57

68
from .validate import StacValidate
79

810

911
@click.command()
1012
@click.argument("stac_file")
13+
@click.option("--lint", is_flag=True, help="Use stac-check to lint stac object.")
1114
@click.option(
1215
"--core", is_flag=True, help="Validate core stac object only without extensions."
1316
)
@@ -47,6 +50,7 @@
4750
@click.version_option(version="2.2.0")
4851
def main(
4952
stac_file,
53+
lint,
5054
recursive,
5155
core,
5256
extensions,
@@ -57,25 +61,30 @@ def main(
5761
no_output,
5862
log_file,
5963
):
60-
stac = StacValidate(
61-
stac_file=stac_file,
62-
recursive=recursive,
63-
core=core,
64-
links=links,
65-
assets=assets,
66-
extensions=extensions,
67-
custom=custom,
68-
verbose=verbose,
69-
no_output=no_output,
70-
log=log_file,
71-
)
72-
stac.run()
7364

74-
if no_output is False:
75-
click.echo(json.dumps(stac.message, indent=4))
65+
if lint is True:
66+
linter = Linter(stac_file, assets=True, links=True, recursive=False)
67+
lint_message(linter)
68+
else:
69+
stac = StacValidate(
70+
stac_file=stac_file,
71+
recursive=recursive,
72+
core=core,
73+
links=links,
74+
assets=assets,
75+
extensions=extensions,
76+
custom=custom,
77+
verbose=verbose,
78+
no_output=no_output,
79+
log=log_file,
80+
)
81+
stac.run()
7682

77-
if recursive == -2 and stac.message[0]["valid_stac"] is False:
78-
sys.exit(1)
83+
if no_output is False:
84+
click.echo(json.dumps(stac.message, indent=4))
85+
86+
if recursive == -2 and stac.message[0]["valid_stac"] is False:
87+
sys.exit(1)
7988

8089

8190
if __name__ == "__main__":

0 commit comments

Comments
 (0)