Source code for tdw_catalog.metadata_template.list_field

from typing import List, Optional

from tdw_catalog.utils import MetadataFieldType
import tdw_catalog.metadata_template.field as field


[docs]class Field(field.MetadataTemplateField[str]): """ A preconfigured set of options where one of the options may be applied to a :class:`.Dataset` Attributes ---------- allow_any : Optional[bool] An optional boolean switch to determine if values not in the list can be entered list_items : Optional[List[str]] An optional list of values from which a user may choose a value """ allow_any: Optional[bool] list_items: Optional[List[str]] def __init__(self, key: str, default_value: Optional[field.T], optional: Optional[bool], allow_any: Optional[bool], list_items: Optional[List[str]]) -> None: super().__init__(key, default_value, optional) self.allow_any = allow_any self.list_items = list_items def serialize(self) -> dict: res = super().serialize() res["default_value"] = self.default_value res["allow_any"] = self.allow_any res["list_items"] = self.list_items res["field_type"] = MetadataFieldType.FT_LIST return res