integration layer; merge work on indicators from forks with existing ingestion pipeline
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"""Common base for every import schema."""
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
from webapi.imports.schemas.coercion import Catalog
|
||||
|
||||
|
||||
class ImportSchema(BaseModel):
|
||||
"""Shared pydantic config for all import schemas.
|
||||
|
||||
`coerce_numbers_to_str`: a numeric source column (SQL INT, Excel number,
|
||||
JSON number) feeding a text field is legitimate: expediente `12345` is "12345".
|
||||
"""
|
||||
|
||||
model_config = ConfigDict(coerce_numbers_to_str=True)
|
||||
|
||||
@classmethod
|
||||
def catalog_for(cls, field_name: str) -> Catalog | None:
|
||||
field = cls.model_fields.get(field_name)
|
||||
if field is None:
|
||||
return None
|
||||
return next((m for m in field.metadata if isinstance(m, Catalog)), None)
|
||||
Reference in New Issue
Block a user