pretalx_client.adapters.normalization

Normalization helpers for Pretalx multilingual and ID-based fields.

Pretalx returns localized fields as either plain strings or dicts keyed by language code (e.g. {"en": "Talk", "de": "Vortrag"}). It also returns foreign-key fields as integer IDs in the real API but as inline objects in the public/legacy API. These helpers normalize both patterns into plain Python strings.

Functions

localized(value)

Extract a display string from a Pretalx multilingual field.

resolve_id_or_localized(value[, mapping])

Resolve a Pretalx field that may be an integer ID or a localized value.

resolve_many_ids_or_localized(values[, mapping])

Resolve a list of Pretalx ID/localized values into display strings.

pretalx_client.adapters.normalization.localized(value)[source]

Extract a display string from a Pretalx multilingual field.

Pretalx returns localized fields as either a plain string or a dict keyed by language code (e.g. {"en": "Talk", "de": "Vortrag"}). This helper returns the en value when available, falling back to the first available language, or an empty string for None.

Parameters:

value (str | dict[str, Any] | None) – A string, a multilingual dict, an object with a name dict, or None.

Return type:

str

Returns:

The resolved display string.

pretalx_client.adapters.normalization.resolve_id_or_localized(value, mapping=None)[source]

Resolve a Pretalx field that may be an integer ID or a localized value.

When the real API returns an integer ID (e.g. for submission_type, track, or room), the optional mapping dict is used to look up the human-readable name. Falls back to localized() for string/dict values, or str(value) for unmapped integers.

Parameters:
  • value (int | str | dict[str, Any] | None) – An integer ID, a string, a multilingual dict, or None.

  • mapping (dict[int, str] | None) – Optional {id: name} dict for resolving integer IDs.

Return type:

str

Returns:

The resolved display string, or empty string for None.

pretalx_client.adapters.normalization.resolve_many_ids_or_localized(values, mapping=None)[source]

Resolve a list of Pretalx ID/localized values into display strings.

Parameters:
Return type:

list[str]