From b3a9344ba861db7e3076b42d08780b9f2c4cfb8e Mon Sep 17 00:00:00 2001 From: Paul van Schayck Date: Thu, 12 Oct 2023 10:15:28 +0200 Subject: [PATCH] Rename base model --- src/edr_pydantic/{my_base_model.py => base_model.py} | 2 +- src/edr_pydantic/capabilities.py | 10 +++++----- src/edr_pydantic/collections.py | 8 ++++---- src/edr_pydantic/data_queries.py | 6 +++--- src/edr_pydantic/extent.py | 10 +++++----- src/edr_pydantic/link.py | 4 ++-- src/edr_pydantic/observed_property.py | 6 +++--- src/edr_pydantic/parameter.py | 6 +++--- src/edr_pydantic/reference_system.py | 9 +++++---- src/edr_pydantic/unit.py | 6 +++--- src/edr_pydantic/variables.py | 4 ++-- 11 files changed, 36 insertions(+), 35 deletions(-) rename src/edr_pydantic/{my_base_model.py => base_model.py} (87%) diff --git a/src/edr_pydantic/my_base_model.py b/src/edr_pydantic/base_model.py similarity index 87% rename from src/edr_pydantic/my_base_model.py rename to src/edr_pydantic/base_model.py index fc66084..9832511 100644 --- a/src/edr_pydantic/my_base_model.py +++ b/src/edr_pydantic/base_model.py @@ -2,7 +2,7 @@ from pydantic import ConfigDict -class EDRBaseModel(PydanticBaseModel): +class EdrBaseModel(PydanticBaseModel): model_config = ConfigDict( str_strip_whitespace=True, extra="forbid", diff --git a/src/edr_pydantic/capabilities.py b/src/edr_pydantic/capabilities.py index c344cf3..0219dbf 100644 --- a/src/edr_pydantic/capabilities.py +++ b/src/edr_pydantic/capabilities.py @@ -3,16 +3,16 @@ from typing import List from typing import Optional +from .base_model import EdrBaseModel from .link import Link -from .my_base_model import EDRBaseModel -class Provider(EDRBaseModel): +class Provider(EdrBaseModel): name: Optional[str] = None url: Optional[str] = None -class Contact(EDRBaseModel): +class Contact(EdrBaseModel): email: Optional[str] = None phone: Optional[str] = None fax: Optional[str] = None @@ -25,7 +25,7 @@ class Contact(EDRBaseModel): country: Optional[str] = None -class LandingPageModel(EDRBaseModel): +class LandingPageModel(EdrBaseModel): links: List[Link] title: Optional[str] = None description: Optional[str] = None @@ -34,5 +34,5 @@ class LandingPageModel(EDRBaseModel): contact: Optional[Contact] = None -class ConformanceModel(EDRBaseModel): +class ConformanceModel(EdrBaseModel): conformsTo: List[str] # noqa: N815 diff --git a/src/edr_pydantic/collections.py b/src/edr_pydantic/collections.py index fc308fb..99a21ac 100644 --- a/src/edr_pydantic/collections.py +++ b/src/edr_pydantic/collections.py @@ -2,14 +2,14 @@ from typing import List from typing import Optional +from .base_model import EdrBaseModel from .data_queries import DataQueries from .extent import Extent from .link import Link -from .my_base_model import EDRBaseModel from .parameter import Parameter -class Collection(EDRBaseModel): +class Collection(EdrBaseModel): id: str title: Optional[str] = None description: Optional[str] = None @@ -25,7 +25,7 @@ class Collection(EDRBaseModel): distanceunits: Optional[List[str]] = None -class Collections(EDRBaseModel): +class Collections(EdrBaseModel): links: List[Link] collections: List[Collection] @@ -35,6 +35,6 @@ class Instance(Collection): pass -class Instances(EDRBaseModel): +class Instances(EdrBaseModel): links: List[Link] instances: List[Instance] diff --git a/src/edr_pydantic/data_queries.py b/src/edr_pydantic/data_queries.py index a49921c..2aceaf3 100644 --- a/src/edr_pydantic/data_queries.py +++ b/src/edr_pydantic/data_queries.py @@ -1,14 +1,14 @@ from typing import Optional +from .base_model import EdrBaseModel from .link import EDRQueryLink -from .my_base_model import EDRBaseModel -class EDRQuery(EDRBaseModel): +class EDRQuery(EdrBaseModel): link: EDRQueryLink -class DataQueries(EDRBaseModel): +class DataQueries(EdrBaseModel): position: Optional[EDRQuery] = None radius: Optional[EDRQuery] = None area: Optional[EDRQuery] = None diff --git a/src/edr_pydantic/extent.py b/src/edr_pydantic/extent.py index 2688f1b..6833fb5 100644 --- a/src/edr_pydantic/extent.py +++ b/src/edr_pydantic/extent.py @@ -3,27 +3,27 @@ from pydantic import AwareDatetime -from .my_base_model import EDRBaseModel +from .base_model import EdrBaseModel -class Spatial(EDRBaseModel): +class Spatial(EdrBaseModel): bbox: List[List[float]] crs: str -class Temporal(EDRBaseModel): +class Temporal(EdrBaseModel): interval: List[List[AwareDatetime]] values: List[str] trs: str -class Vertical(EDRBaseModel): +class Vertical(EdrBaseModel): interval: List[List[str]] values: List[str] vrs: str -class Extent(EDRBaseModel): +class Extent(EdrBaseModel): spatial: Spatial temporal: Optional[Temporal] = None vertical: Optional[Vertical] = None diff --git a/src/edr_pydantic/link.py b/src/edr_pydantic/link.py index 022586b..ce7efb4 100644 --- a/src/edr_pydantic/link.py +++ b/src/edr_pydantic/link.py @@ -1,7 +1,7 @@ from typing import Optional from typing import Union -from .my_base_model import EDRBaseModel +from .base_model import EdrBaseModel from .variables import CorridorVariables from .variables import CubeVariables from .variables import ItemVariables @@ -9,7 +9,7 @@ from .variables import Variables -class Link(EDRBaseModel): +class Link(EdrBaseModel): href: str hreflang: Optional[str] = None rel: str diff --git a/src/edr_pydantic/observed_property.py b/src/edr_pydantic/observed_property.py index f6ea60c..ac7a4f5 100644 --- a/src/edr_pydantic/observed_property.py +++ b/src/edr_pydantic/observed_property.py @@ -1,16 +1,16 @@ from typing import List from typing import Optional -from .my_base_model import EDRBaseModel +from .base_model import EdrBaseModel -class Category(EDRBaseModel): +class Category(EdrBaseModel): id: str label: str description: Optional[str] = None -class ObservedProperty(EDRBaseModel): +class ObservedProperty(EdrBaseModel): id: Optional[str] = None label: str description: Optional[str] = None diff --git a/src/edr_pydantic/parameter.py b/src/edr_pydantic/parameter.py index be3ceb3..6a4b9b6 100644 --- a/src/edr_pydantic/parameter.py +++ b/src/edr_pydantic/parameter.py @@ -4,12 +4,12 @@ from pydantic import model_validator -from .my_base_model import EDRBaseModel +from .base_model import EdrBaseModel from .observed_property import ObservedProperty from .unit import Unit -class Parameter(EDRBaseModel, extra="allow"): +class Parameter(EdrBaseModel, extra="allow"): type: Literal["Parameter"] = "Parameter" id: Optional[str] = None label: Optional[str] = None @@ -28,7 +28,7 @@ def must_not_have_unit_if_observed_property_has_categories(self): return self -class ParameterGroup(EDRBaseModel, extra="allow"): +class ParameterGroup(EdrBaseModel, extra="allow"): type: Literal["ParameterGroup"] = "ParameterGroup" id: Optional[str] = None label: Optional[str] = None diff --git a/src/edr_pydantic/reference_system.py b/src/edr_pydantic/reference_system.py index db612cd..51cf3a4 100644 --- a/src/edr_pydantic/reference_system.py +++ b/src/edr_pydantic/reference_system.py @@ -1,6 +1,7 @@ -from .my_base_model import EDRBaseModel +from .base_model import EdrBaseModel -class CRS(EDRBaseModel): - name: str # MAY EPSG code - wkt: str # SHALL Well Known Text +class CRS(EdrBaseModel): + name: str # # This MAY be an EPSG code + # TODO: Implement WKT (Well Known Text) validator + wkt: str diff --git a/src/edr_pydantic/unit.py b/src/edr_pydantic/unit.py index 860677e..08110a2 100644 --- a/src/edr_pydantic/unit.py +++ b/src/edr_pydantic/unit.py @@ -3,15 +3,15 @@ from pydantic import model_validator -from .my_base_model import EDRBaseModel +from .base_model import EdrBaseModel -class Symbol(EDRBaseModel, extra="allow"): +class Symbol(EdrBaseModel, extra="allow"): value: str type: str -class Unit(EDRBaseModel): +class Unit(EdrBaseModel): id: Optional[str] = None label: Optional[str] = None symbol: Optional[Union[str, Symbol]] = None diff --git a/src/edr_pydantic/variables.py b/src/edr_pydantic/variables.py index b9c1f59..bbfe6f5 100644 --- a/src/edr_pydantic/variables.py +++ b/src/edr_pydantic/variables.py @@ -1,10 +1,10 @@ from typing import List from typing import Optional -from .my_base_model import EDRBaseModel +from .base_model import EdrBaseModel -class Variables(EDRBaseModel, extra="allow"): +class Variables(EdrBaseModel, extra="allow"): # TODO query_type required? Not according to C.3 query_type: str output_formats: Optional[List[str]] = None