Skip to content

Commit 40a44dc

Browse files
committed
feat: Added ProcessingLevel options and validation
1 parent 278ecf4 commit 40a44dc

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

pystac/extensions/processing.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
ExtensionManagementMixin,
2121
PropertiesExtension,
2222
)
23-
from pystac.utils import StringEnum
23+
from pystac.utils import StringEnum, datetime_to_str, map_opt, str_to_datetime
2424

2525
T = TypeVar("T", pystac.Item, pystac.Asset, item_assets.AssetDefinition)
2626

@@ -44,7 +44,11 @@ class ProcessingLevel(StringEnum):
4444
RAW = "RAW"
4545
L0 = "L0"
4646
L1 = "L1"
47+
L1A = "L1A"
48+
L1B = "L1B"
49+
L1C = "L1C"
4750
L2 = "L2"
51+
L2A = "L2A"
4852
L3 = "L3"
4953
L4 = "L4"
5054

@@ -81,12 +85,15 @@ def apply(self: Self, level: str | None = None) -> None:
8185
self.level = level
8286

8387
@property
84-
def level(self: Self) -> str | None:
85-
return self._get_property(LEVEL_PROP, str)
88+
def level(self: Self) -> ProcessingLevel | None:
89+
"""Get or sets the processing level of the object."""
90+
return map_opt(
91+
lambda x: ProcessingLevel(x), self._get_property(LEVEL_PROP, str)
92+
)
8693

8794
@level.setter
88-
def level(self: Self, v: str | None) -> None:
89-
self._set_property(LEVEL_PROP, v, pop_if_none=True)
95+
def level(self: Self, v: ProcessingLevel | None) -> None:
96+
self._set_property(LEVEL_PROP, map_opt(lambda x: x.value, v), pop_if_none=True)
9097

9198
@property
9299
def datetime(self: Self) -> str | None:

0 commit comments

Comments
 (0)