setting¶
This module implements the dataset settings as a thin pydantic wrapper on top of sayt2 field types.
- class afwf_fts_anything.setting.Setting(*, fields: list[Annotated[StoredField | KeywordField | TextField | NgramField | NumericField | DatetimeField | BooleanField, FieldInfo(annotation=NoneType, required=True, discriminator='type')]], sort: list[SortKey] | None = None, title_field: str | None = None, subtitle_field: str | None = None, arg_field: str | None = None, autocomplete_field: str | None = None, icon_field: str | None = None, data_url: str | None = None)[source]¶
Defines how you want to index your dataset.
- Parameters:
fields – list of sayt2 field objects (StoredField, NgramField, TextField, KeywordField, NumericField, DatetimeField, BooleanField).
title_field – template string for
WorkflowItem.title, e.g."{title} [{genres}]". If None, a field named"title"must exist.subtitle_field – template string for
WorkflowItem.subtitle.arg_field – template string for
WorkflowItem.arg.autocomplete_field – template string for
WorkflowItem.autocomplete.icon_field – template string for
WorkflowItem.icon.data_url – optional URL to download the dataset JSON from.
- property fields_mapper: dict[str, Annotated[StoredField | KeywordField | TextField | NgramField | NumericField | DatetimeField | BooleanField, FieldInfo(annotation=NoneType, required=True, discriminator='type')]]¶
Return a mapping of field name to field object.
- property sortable_fields: list[str]¶
Names of all fast-sortable fields (NumericField or DatetimeField with
fast=True).
- classmethod from_json_file(path: str | Path) Setting[source]¶
Load a
Settingfrom a JSON file at path.
- format_title(data: dict[str, object]) str[source]¶
Return the Alfred title string for data.
If
title_fieldisNone, returnsdata["title"]. Otherwise renderstitle_fieldas astr.format_map()template.
- format_subtitle(data: dict[str, object]) str | None[source]¶
Return the Alfred subtitle string for data, or
Noneif not configured.
- format_arg(data: dict[str, object]) str | None[source]¶
Return the Alfred arg string for data, or
Noneif not configured.
- format_autocomplete(data: dict[str, object]) str | None[source]¶
Return the Alfred autocomplete string for data, or
Noneif not configured.
- format_icon(data: dict[str, object]) str | None[source]¶
Return the Alfred icon path for data, or
Noneif not configured.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].