core.converters =============== .. py:module:: core.converters .. autoapi-nested-parse:: Contains custom converters. Attributes ---------- .. autoapisummary:: core.converters.extended_date_converter core.converters.json_converter core.converters.uuid_converter core.converters.bool_converter core.converters.datetime_converter core.converters.datetime_year_converter core.converters.integer_range_converter core.converters.move_direction_converter core.converters.LiteralConverterBase Classes ------- .. autoapisummary:: core.converters.LiteralConverter Functions --------- .. autoapisummary:: core.converters.extended_date_decode core.converters.extended_date_encode core.converters.json_decode core.converters.json_encode core.converters.uuid_decode core.converters.uuid_encode core.converters.get_default_uuid_converter core.converters.bool_decode core.converters.bool_encode core.converters.get_default_bool_converter core.converters.datetime_decode core.converters.datetime_encode core.converters.datetime_year_decode core.converters.datetime_year_encode core.converters.get_default_datetime_converter core.converters.integer_range_decode core.converters.integer_range_encode core.converters.move_direction_decode core.converters.move_direction_encode core.converters.get_default_move_direction_converter Module Contents --------------- .. py:function:: extended_date_decode(s: Literal['']) -> None extended_date_decode(s: str) -> datetime.date Decodes a date string HTML5 (RFC3339) compliant. .. py:function:: extended_date_encode(d: datetime.date | None) -> str Encodes a date HTML5 (RFC3339) compliant. .. py:data:: extended_date_converter .. py:function:: json_decode(s: Literal['']) -> None json_decode(s: str) -> dict[str, Any] Decodes a json string to a dict. .. py:function:: json_encode(d: collections.abc.Mapping[str, Any] | None) -> str Encodes a dictionary to json. .. py:data:: json_converter .. py:function:: uuid_decode(s: str) -> uuid.UUID | None Turns a uuid string into a UUID instance. .. py:function:: uuid_encode(uuid: uuid.UUID | str | None) -> str Turns a UUID instance into a uuid string. .. py:data:: uuid_converter .. py:function:: get_default_uuid_converter() -> morepath.Converter[uuid.UUID] .. py:function:: bool_decode(s: Literal['0', '']) -> Literal[False] bool_decode(s: Literal['1']) -> Literal[True] bool_decode(s: str) -> bool Decodes a boolean. .. py:function:: bool_encode(d: Literal[False] | None) -> Literal['0'] bool_encode(d: Literal[True]) -> Literal['1'] bool_encode(d: bool | None) -> Literal['0', '1'] Encodes a boolean. .. py:data:: bool_converter :type: morepath.Converter[bool] .. py:function:: get_default_bool_converter() -> morepath.Converter[bool] .. py:function:: datetime_decode(s: Literal['']) -> None datetime_decode(s: str) -> datetime.datetime Decodes a datetime. .. py:function:: datetime_encode(d: datetime.datetime | None) -> str Encodes a datetime. .. py:data:: datetime_converter .. py:function:: datetime_year_decode(s: str) -> int Decodes a year limited to the range datetime provides. .. py:function:: datetime_year_encode(y: int | None) -> str Encodes a year. .. py:data:: datetime_year_converter .. py:function:: get_default_datetime_converter() -> morepath.Converter[datetime.datetime] .. py:function:: integer_range_decode(s: str) -> tuple[int, int] | None .. py:function:: integer_range_encode(t: tuple[int, int] | None) -> str .. py:data:: integer_range_converter .. py:function:: move_direction_decode(s: str) -> onegov.core.orm.abstract.MoveDirection | None .. py:function:: move_direction_encode(d: str | onegov.core.orm.abstract.MoveDirection | None) -> str .. py:data:: move_direction_converter .. py:function:: get_default_move_direction_converter() -> morepath.Converter[onegov.core.orm.abstract.MoveDirection] .. py:data:: LiteralConverterBase .. py:class:: LiteralConverter(literal_type: Any, /) LiteralConverter(*literals: LiteralString) Bases: :py:obj:`LiteralConverterBase` This is a ``Converter`` counter-part to ``typing.Literal``. .. py:attribute:: allowed_values :type: set[str] .. py:method:: single_decode(string: str) -> str | None .. py:method:: single_encode(value: str | None) -> str