stac-pydantic-extensions 0.1.0__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.
Files changed (28) hide show
  1. stac_pydantic_extensions-0.1.0/LICENSE +21 -0
  2. stac_pydantic_extensions-0.1.0/PKG-INFO +187 -0
  3. stac_pydantic_extensions-0.1.0/README.md +139 -0
  4. stac_pydantic_extensions-0.1.0/pyproject.toml +73 -0
  5. stac_pydantic_extensions-0.1.0/pyproject.toml.orig +61 -0
  6. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/__init__.py +33 -0
  7. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/_registry.py +83 -0
  8. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/cli.py +18 -0
  9. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/compat/__init__.py +0 -0
  10. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/compat/stac_pydantic.py +141 -0
  11. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extended.py +375 -0
  12. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extensions/__init__.py +0 -0
  13. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extensions/_base.py +341 -0
  14. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extensions/_projjson.py +646 -0
  15. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extensions/cube.py +145 -0
  16. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extensions/eo.py +416 -0
  17. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extensions/processing.py +188 -0
  18. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extensions/proj.py +216 -0
  19. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extensions/raster.py +378 -0
  20. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extensions/rd.py +110 -0
  21. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extensions/sat.py +179 -0
  22. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extensions/sci.py +124 -0
  23. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extensions/ssys.py +115 -0
  24. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extensions/view.py +143 -0
  25. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/extensions/wmts.py +195 -0
  26. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/model_annotations.py +28 -0
  27. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/types.py +83 -0
  28. stac_pydantic_extensions-0.1.0/src/stac_pydantic_extensions/validators.py +118 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Arturo AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,187 @@
1
+ Metadata-Version: 2.3
2
+ Name: stac-pydantic-extensions
3
+ Version: 0.1.0
4
+ Summary: Pydantic data models for STAC extensions
5
+ Keywords: geospatial,gis,pydantic,stac,stac-extensions
6
+ Author: Shadi Boomi
7
+ Author-email: Shadi Boomi <shadi.boomi@universite-paris-saclay.fr>
8
+ License: MIT License
9
+
10
+ Copyright (c) 2020 Arturo AI
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
29
+ Classifier: Development Status :: 3 - Alpha
30
+ Classifier: Intended Audience :: Developers
31
+ Classifier: Intended Audience :: Science/Research
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: Programming Language :: Python :: 3.13
35
+ Classifier: Programming Language :: Python :: 3.14
36
+ Classifier: Topic :: Scientific/Engineering :: GIS
37
+ Classifier: Typing :: Typed
38
+ Requires-Dist: geojson-pydantic>=2.1.1
39
+ Requires-Dist: pydantic>=2.13.4
40
+ Requires-Dist: pyproj>=3.7.2
41
+ Requires-Dist: stac-pydantic>=3.5.1
42
+ Requires-Dist: typer>=0.27.1
43
+ Requires-Python: >=3.13
44
+ Project-URL: Homepage, https://github.com/s-boomi/stac-pydantic-extensions
45
+ Project-URL: Issues, https://github.com/s-boomi/stac-pydantic-extensions/issues
46
+ Project-URL: Repository, https://github.com/s-boomi/stac-pydantic-extensions
47
+ Description-Content-Type: text/markdown
48
+
49
+ # stac-pydantic-extensions
50
+
51
+ [![CI](https://github.com/s-boomi/stac-pydantic-extensions/actions/workflows/cicd.yml/badge.svg)](https://github.com/s-boomi/stac-pydantic-extensions/actions/workflows/cicd.yml)
52
+ [![PyPI version](https://img.shields.io/pypi/v/stac-pydantic-extensions.svg)](https://pypi.org/project/stac-pydantic-extensions/)
53
+ [![Python versions](https://img.shields.io/pypi/pyversions/stac-pydantic-extensions.svg)](https://pypi.org/project/stac-pydantic-extensions/)
54
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
55
+
56
+ Pydantic data models for [STAC extensions](https://github.com/stac-extensions), built on top of
57
+ [`stac-pydantic`](https://github.com/stac-utils/stac-pydantic).
58
+
59
+ `stac-pydantic-extensions` lets you attach, read, modify, and migrate STAC extension fields
60
+ (`eo`, `raster`, `proj`, `view`, `sat`, `sci`, `rd`, `ssys`, `wmts`, ...) on Items, Collections,
61
+ Assets and Bands, with validation and version migration handled for you.
62
+
63
+ ## Features
64
+
65
+ - **Typed access to extension fields** — `item.ext.eo.cloud_cover`, `item.ext.raster.spatial_resolution`, etc.
66
+ - **Add / remove extensions** on the fly, recursively across assets and bands.
67
+ - **Version migration** — upgrade Items written against older extension schemas (e.g. `eo/v1.0.0`,
68
+ `raster/v1.1.0`) to the current ones, including the `eo:bands` / `raster:bands` → `bands` merge
69
+ introduced in the `v2.0.0` extensions.
70
+ - **Multiple extensions at once**, without them clobbering each other's fields.
71
+ - Works with plain STAC Items that don't declare any extensions yet.
72
+
73
+ ## Installation
74
+
75
+ ```bash
76
+ pip install stac-pydantic-extensions
77
+ ```
78
+
79
+ or, with [uv](https://docs.astral.sh/uv/):
80
+
81
+ ```bash
82
+ uv add stac-pydantic-extensions
83
+ ```
84
+
85
+ Requires Python 3.13+.
86
+
87
+ ## Quickstart
88
+
89
+ ```python
90
+ import json
91
+
92
+ from stac_pydantic_extensions import ExtendedItem, Item
93
+
94
+ with open("item-sentinel2.json") as f:
95
+ raw_item = json.load(f)
96
+
97
+ item = Item.model_validate(raw_item)
98
+ extended_item = ExtendedItem(stac_object=item)
99
+
100
+ # Read extension fields declared on the item
101
+ print(extended_item.ext.eo.cloud_cover) # 21.22
102
+ print(extended_item.show_ext_names()) # {'eo', 'view', 'proj', 'raster'}
103
+
104
+ # Extensions declared on assets/bands are available the same way
105
+ red_band = extended_item.stac_object.assets["B04"]
106
+ extended_band = ExtendedItem(stac_object=red_band)
107
+ print(extended_band.ext.eo.common_name) # "red"
108
+ print(extended_band.ext.raster.spatial_resolution) # 10
109
+
110
+ # Add a new extension to an item that doesn't have it yet
111
+ extended_item.add_extension("raster")
112
+ extended_item.ext.raster.spatial_resolution = 10
113
+
114
+ # Serialize back out
115
+ updated = extended_item.model_dump()
116
+ ```
117
+
118
+ ### Migrating older extension versions
119
+
120
+ ```python
121
+ from stac_pydantic_extensions import ExtendedItem, Item
122
+
123
+ old_item = Item.model_validate(raw_item_with_v1_extensions)
124
+
125
+ migrated = ExtendedItem(stac_object=old_item).migrate()
126
+ # stac_extensions now point at the latest schema versions, and any
127
+ # eo:bands / raster:bands entries have been merged into `bands`.
128
+ ```
129
+
130
+ ## Supported extensions
131
+
132
+ | Extension | Prefix |
133
+ |-------------------------|----------|
134
+ | Electro-Optical | `eo` |
135
+ | Projection | `proj` |
136
+ | Raster | `raster` |
137
+ | View Geometry | `view` |
138
+ | Satellite | `sat` |
139
+ | Scientific Citation | `sci` |
140
+ | Remote Data | `rd` |
141
+ | Solar System | `ssys` |
142
+ | Web Map Tile Service | `wmts` |
143
+
144
+ ## Development
145
+
146
+ This project uses [uv](https://docs.astral.sh/uv/) for dependency management.
147
+
148
+ ```bash
149
+ git clone https://github.com/s-boomi/stac-pydantic-extensions.git
150
+ cd stac-pydantic-extensions
151
+ uv sync --group dev
152
+ ```
153
+
154
+ Run the test suite:
155
+
156
+ ```bash
157
+ uv run pytest --cov stac_pydantic_extensions --cov-report term-missing
158
+ ```
159
+
160
+ Run linting, formatting and type checks:
161
+
162
+ ```bash
163
+ uv run pre-commit run --all-files
164
+ uv run ty check
165
+ ```
166
+
167
+ > [!WARNING]
168
+ > The `ty` check is still relatively new and can be prone to some errors, especially in test files. To skip type-checking, you can use the following command:
169
+
170
+ ```console
171
+ SKIP=ty uv run pre-commit run --all-files
172
+ ```
173
+
174
+ ## Releasing
175
+
176
+ Releases are published to PyPI via [PyPI trusted publishing](https://docs.pypi.org/trusted-publishers/)
177
+ from the `.github/workflows/release.yml` workflow. To cut a release:
178
+
179
+ 1. Bump `version` in `pyproject.toml`.
180
+ 2. Tag the commit with the matching version (e.g. `v0.2.0`) and push the tag, or create a
181
+ GitHub Release — this triggers the `release` job.
182
+ 3. The workflow verifies the tag matches the package version, builds the sdist/wheel with
183
+ `uv build`, and publishes with `uv publish`.
184
+
185
+ ## License
186
+
187
+ Distributed under the MIT License. See [`LICENSE`](LICENSE) for details.
@@ -0,0 +1,139 @@
1
+ # stac-pydantic-extensions
2
+
3
+ [![CI](https://github.com/s-boomi/stac-pydantic-extensions/actions/workflows/cicd.yml/badge.svg)](https://github.com/s-boomi/stac-pydantic-extensions/actions/workflows/cicd.yml)
4
+ [![PyPI version](https://img.shields.io/pypi/v/stac-pydantic-extensions.svg)](https://pypi.org/project/stac-pydantic-extensions/)
5
+ [![Python versions](https://img.shields.io/pypi/pyversions/stac-pydantic-extensions.svg)](https://pypi.org/project/stac-pydantic-extensions/)
6
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
+
8
+ Pydantic data models for [STAC extensions](https://github.com/stac-extensions), built on top of
9
+ [`stac-pydantic`](https://github.com/stac-utils/stac-pydantic).
10
+
11
+ `stac-pydantic-extensions` lets you attach, read, modify, and migrate STAC extension fields
12
+ (`eo`, `raster`, `proj`, `view`, `sat`, `sci`, `rd`, `ssys`, `wmts`, ...) on Items, Collections,
13
+ Assets and Bands, with validation and version migration handled for you.
14
+
15
+ ## Features
16
+
17
+ - **Typed access to extension fields** — `item.ext.eo.cloud_cover`, `item.ext.raster.spatial_resolution`, etc.
18
+ - **Add / remove extensions** on the fly, recursively across assets and bands.
19
+ - **Version migration** — upgrade Items written against older extension schemas (e.g. `eo/v1.0.0`,
20
+ `raster/v1.1.0`) to the current ones, including the `eo:bands` / `raster:bands` → `bands` merge
21
+ introduced in the `v2.0.0` extensions.
22
+ - **Multiple extensions at once**, without them clobbering each other's fields.
23
+ - Works with plain STAC Items that don't declare any extensions yet.
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install stac-pydantic-extensions
29
+ ```
30
+
31
+ or, with [uv](https://docs.astral.sh/uv/):
32
+
33
+ ```bash
34
+ uv add stac-pydantic-extensions
35
+ ```
36
+
37
+ Requires Python 3.13+.
38
+
39
+ ## Quickstart
40
+
41
+ ```python
42
+ import json
43
+
44
+ from stac_pydantic_extensions import ExtendedItem, Item
45
+
46
+ with open("item-sentinel2.json") as f:
47
+ raw_item = json.load(f)
48
+
49
+ item = Item.model_validate(raw_item)
50
+ extended_item = ExtendedItem(stac_object=item)
51
+
52
+ # Read extension fields declared on the item
53
+ print(extended_item.ext.eo.cloud_cover) # 21.22
54
+ print(extended_item.show_ext_names()) # {'eo', 'view', 'proj', 'raster'}
55
+
56
+ # Extensions declared on assets/bands are available the same way
57
+ red_band = extended_item.stac_object.assets["B04"]
58
+ extended_band = ExtendedItem(stac_object=red_band)
59
+ print(extended_band.ext.eo.common_name) # "red"
60
+ print(extended_band.ext.raster.spatial_resolution) # 10
61
+
62
+ # Add a new extension to an item that doesn't have it yet
63
+ extended_item.add_extension("raster")
64
+ extended_item.ext.raster.spatial_resolution = 10
65
+
66
+ # Serialize back out
67
+ updated = extended_item.model_dump()
68
+ ```
69
+
70
+ ### Migrating older extension versions
71
+
72
+ ```python
73
+ from stac_pydantic_extensions import ExtendedItem, Item
74
+
75
+ old_item = Item.model_validate(raw_item_with_v1_extensions)
76
+
77
+ migrated = ExtendedItem(stac_object=old_item).migrate()
78
+ # stac_extensions now point at the latest schema versions, and any
79
+ # eo:bands / raster:bands entries have been merged into `bands`.
80
+ ```
81
+
82
+ ## Supported extensions
83
+
84
+ | Extension | Prefix |
85
+ |-------------------------|----------|
86
+ | Electro-Optical | `eo` |
87
+ | Projection | `proj` |
88
+ | Raster | `raster` |
89
+ | View Geometry | `view` |
90
+ | Satellite | `sat` |
91
+ | Scientific Citation | `sci` |
92
+ | Remote Data | `rd` |
93
+ | Solar System | `ssys` |
94
+ | Web Map Tile Service | `wmts` |
95
+
96
+ ## Development
97
+
98
+ This project uses [uv](https://docs.astral.sh/uv/) for dependency management.
99
+
100
+ ```bash
101
+ git clone https://github.com/s-boomi/stac-pydantic-extensions.git
102
+ cd stac-pydantic-extensions
103
+ uv sync --group dev
104
+ ```
105
+
106
+ Run the test suite:
107
+
108
+ ```bash
109
+ uv run pytest --cov stac_pydantic_extensions --cov-report term-missing
110
+ ```
111
+
112
+ Run linting, formatting and type checks:
113
+
114
+ ```bash
115
+ uv run pre-commit run --all-files
116
+ uv run ty check
117
+ ```
118
+
119
+ > [!WARNING]
120
+ > The `ty` check is still relatively new and can be prone to some errors, especially in test files. To skip type-checking, you can use the following command:
121
+
122
+ ```console
123
+ SKIP=ty uv run pre-commit run --all-files
124
+ ```
125
+
126
+ ## Releasing
127
+
128
+ Releases are published to PyPI via [PyPI trusted publishing](https://docs.pypi.org/trusted-publishers/)
129
+ from the `.github/workflows/release.yml` workflow. To cut a release:
130
+
131
+ 1. Bump `version` in `pyproject.toml`.
132
+ 2. Tag the commit with the matching version (e.g. `v0.2.0`) and push the tag, or create a
133
+ GitHub Release — this triggers the `release` job.
134
+ 3. The workflow verifies the tag matches the package version, builds the sdist/wheel with
135
+ `uv build`, and publishes with `uv publish`.
136
+
137
+ ## License
138
+
139
+ Distributed under the MIT License. See [`LICENSE`](LICENSE) for details.
@@ -0,0 +1,73 @@
1
+ [project]
2
+ name = "stac-pydantic-extensions"
3
+ version = "0.1.0"
4
+ description = "Pydantic data models for STAC extensions"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+ keywords = [
8
+ "geospatial",
9
+ "gis",
10
+ "pydantic",
11
+ "stac",
12
+ "stac-extensions",
13
+ ]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Intended Audience :: Developers",
17
+ "Intended Audience :: Science/Research",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Programming Language :: Python :: 3.14",
22
+ "Topic :: Scientific/Engineering :: GIS",
23
+ "Typing :: Typed",
24
+ ]
25
+ dependencies = [
26
+ "geojson-pydantic>=2.1.1",
27
+ "pydantic>=2.13.4",
28
+ "pyproj>=3.7.2",
29
+ "stac-pydantic>=3.5.1",
30
+ "typer>=0.27.1",
31
+ ]
32
+
33
+ [project.license]
34
+ file = "LICENSE"
35
+
36
+ [[project.authors]]
37
+ name = "Shadi Boomi"
38
+ email = "shadi.boomi@universite-paris-saclay.fr"
39
+
40
+ [project.urls]
41
+ Homepage = "https://github.com/s-boomi/stac-pydantic-extensions"
42
+ Issues = "https://github.com/s-boomi/stac-pydantic-extensions/issues"
43
+ Repository = "https://github.com/s-boomi/stac-pydantic-extensions"
44
+
45
+ [project.scripts]
46
+ stac-pydantic-extensions = "stac_pydantic_extensions.cli:app"
47
+
48
+ [dependency-groups]
49
+ dev = [
50
+ "jsonschema>=4.26.0",
51
+ "pre-commit>=4.6.0",
52
+ "pytest>=9.0.3",
53
+ "pytest-cov>=7.1.0",
54
+ "pytest-icdiff>=0.9",
55
+ "requests>=2.34.2",
56
+ "ruff>=0.15.13",
57
+ "tombi>=0.11.5",
58
+ "ty>=0.0.37",
59
+ ]
60
+
61
+ [build-system]
62
+ requires = ["uv_build>=0.11.9,<0.12.0"]
63
+ build-backend = "uv_build"
64
+
65
+ [tool.ty.src]
66
+ include = [
67
+ "src",
68
+ "tests",
69
+ ]
70
+ exclude = [".venv"]
71
+
72
+ [tool.ty.environment]
73
+ python = ".venv"
@@ -0,0 +1,61 @@
1
+ [project]
2
+ name = "stac-pydantic-extensions"
3
+ version = "0.1.0"
4
+ description = "Pydantic data models for STAC extensions"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+ license = { file = "LICENSE" }
8
+ authors = [
9
+ { name = "Shadi Boomi", email = "shadi.boomi@universite-paris-saclay.fr" }
10
+ ]
11
+ keywords = ["geospatial", "gis", "pydantic", "stac", "stac-extensions"]
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Developers",
15
+ "Intended Audience :: Science/Research",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Programming Language :: Python :: 3.14",
20
+ "Topic :: Scientific/Engineering :: GIS",
21
+ "Typing :: Typed",
22
+ ]
23
+ dependencies = [
24
+ "geojson-pydantic>=2.1.1",
25
+ "pydantic>=2.13.4",
26
+ "pyproj>=3.7.2",
27
+ "stac-pydantic>=3.5.1",
28
+ "typer>=0.27.1",
29
+ ]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/s-boomi/stac-pydantic-extensions"
33
+ Issues = "https://github.com/s-boomi/stac-pydantic-extensions/issues"
34
+ Repository = "https://github.com/s-boomi/stac-pydantic-extensions"
35
+
36
+ [project.scripts]
37
+ stac-pydantic-extensions = "stac_pydantic_extensions.cli:app"
38
+
39
+ [dependency-groups]
40
+ dev = [
41
+ "jsonschema>=4.26.0",
42
+ "pre-commit>=4.6.0",
43
+ "pytest>=9.0.3",
44
+ "pytest-cov>=7.1.0",
45
+ "pytest-icdiff>=0.9",
46
+ "requests>=2.34.2",
47
+ "ruff>=0.15.13",
48
+ "tombi>=0.11.5",
49
+ "ty>=0.0.37",
50
+ ]
51
+
52
+ [build-system]
53
+ requires = ["uv_build>=0.11.9,<0.12.0"]
54
+ build-backend = "uv_build"
55
+
56
+ [tool.ty.src]
57
+ include = ["src", "tests"]
58
+ exclude = [".venv"]
59
+
60
+ [tool.ty.environment]
61
+ python = ".venv"
@@ -0,0 +1,33 @@
1
+ """STAC Pydantic Extensions."""
2
+
3
+ from stac_pydantic_extensions.compat.stac_pydantic import (
4
+ STAC_VERSION,
5
+ Asset,
6
+ Band,
7
+ Collection,
8
+ DataTypes,
9
+ Item,
10
+ ItemAsset,
11
+ ItemProperties,
12
+ Link,
13
+ NoDataTypes,
14
+ StacCommonMetadata,
15
+ Statistics,
16
+ )
17
+ from stac_pydantic_extensions.extended import ExtendedItem
18
+
19
+ __all__: list[str] = [
20
+ "STAC_VERSION",
21
+ "NoDataTypes",
22
+ "DataTypes",
23
+ "Band",
24
+ "Statistics",
25
+ "StacCommonMetadata",
26
+ "Link",
27
+ "Asset",
28
+ "ItemAsset",
29
+ "Collection",
30
+ "ItemProperties",
31
+ "Item",
32
+ "ExtendedItem",
33
+ ]
@@ -0,0 +1,83 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Any, Optional, Type
4
+
5
+ from pydantic import Field
6
+
7
+ from stac_pydantic_extensions.extensions._base import BaseExtension
8
+ from stac_pydantic_extensions.extensions.eo import ElectroOpticalExtension
9
+ from stac_pydantic_extensions.extensions.processing import ProcessingExtension
10
+ from stac_pydantic_extensions.extensions.proj import ProjectionExtension
11
+ from stac_pydantic_extensions.extensions.raster import RasterExtension
12
+ from stac_pydantic_extensions.extensions.rd import RemoteDataExtension
13
+ from stac_pydantic_extensions.extensions.sat import SatelliteExtension
14
+ from stac_pydantic_extensions.extensions.sci import ScientificCitationExtension
15
+ from stac_pydantic_extensions.extensions.ssys import SolSysExtension
16
+ from stac_pydantic_extensions.extensions.view import ViewGeometryExtension
17
+ from stac_pydantic_extensions.extensions.wmts import WebMapLinksExtension
18
+
19
+ if TYPE_CHECKING:
20
+ from stac_pydantic_extensions.extended import ExtendableStacObject
21
+
22
+ AVAILABLE_EXTENSIONS: list[Type[BaseExtension]] = [
23
+ ElectroOpticalExtension,
24
+ SolSysExtension,
25
+ WebMapLinksExtension,
26
+ ProjectionExtension,
27
+ RemoteDataExtension,
28
+ ScientificCitationExtension,
29
+ ViewGeometryExtension,
30
+ RasterExtension,
31
+ SatelliteExtension,
32
+ ProcessingExtension,
33
+ ]
34
+
35
+
36
+ class _ExtensionRegistry:
37
+ @staticmethod
38
+ def _set_extensions(
39
+ extensions: list[type[BaseExtension]],
40
+ ) -> dict[str, type[BaseExtension]]:
41
+ return {extension.prefix: extension for extension in extensions}
42
+
43
+ def __init__(self, extensions: list[Type[BaseExtension]]):
44
+ self._ext: dict[str, type[BaseExtension]] = self._set_extensions(extensions)
45
+
46
+ @property
47
+ def ext(self) -> dict[str, Type[BaseExtension]]:
48
+ return self._ext
49
+
50
+ @ext.setter
51
+ def ext(self, _v: dict[str, Type[BaseExtension]]) -> None:
52
+ self._ext = _v
53
+
54
+ def allowed_extensions_by_stac_item(
55
+ self, stac_object: ExtendableStacObject
56
+ ) -> dict[str, Type[BaseExtension]]:
57
+ return {
58
+ k: v
59
+ for k, v in self.ext.items()
60
+ if stac_object.__class__.__name__ in v.allowed_objects
61
+ }
62
+
63
+ def create_model_fields_by_stac_item(
64
+ self, stac_object: ExtendableStacObject
65
+ ) -> dict[str, tuple[Any, Any]]:
66
+ # First element is a typing expression (Optional[Type]) which isn't a
67
+ # runtime 'type', so use Any in the return annotation to satisfy
68
+ # type-checkers.
69
+ return {
70
+ k: (Optional[v], Field(default=None)) # ty:ignore[invalid-type-form]
71
+ for k, v in self.ext.items()
72
+ if stac_object.__class__.__name__ in v.allowed_objects
73
+ }
74
+
75
+ def __repr__(self) -> str:
76
+ return f"<{self.__class__.__name__} extensions={[ext_name for ext_name in self.ext.keys()]}>"
77
+
78
+ def __str__(self) -> str:
79
+ return f"Registered extensions: {', '.join([ext_name for ext_name in self.ext.keys()])}"
80
+
81
+
82
+ # For export
83
+ extension_registry = _ExtensionRegistry(AVAILABLE_EXTENSIONS)
@@ -0,0 +1,18 @@
1
+ import typer
2
+
3
+ app = typer.Typer()
4
+
5
+
6
+ @app.callback()
7
+ def callback():
8
+ """
9
+ STAC Pydantic Extensions
10
+ """
11
+
12
+
13
+ @app.command()
14
+ def migrate():
15
+ """
16
+ Takes an item and migrates it to the latest versions
17
+ """
18
+ pass