ocracy.translation#
Parameter translation between ocracy’s normalized kwargs and native engines.
Every backend exposes its own parameter names and scales (lang vs
languages vs language_hints; thresholds in 0..1 vs 0..100; pixel
vs point units). A backend declares a param_map in its BACKEND_CONFIG
mapping normalized names to native ones, and make_kwargs_translator()
turns that declaration into a function that rewrites caller kwargs into the
shape the engine wants.
The machinery lives in the facade kit (ocracy.kit.translation), shared
with the fleet’s other facades; this module keeps ocracy’s original
translate(**kwargs) -> dict shape for existing callers. New code that wants
the drops and clamps as notes uses ocracy.kit.make_translator() directly,
as BaseOcrAdapter does.
Functions
|
Create a function that translates normalized kwargs to native kwargs. |
|
Validate a single parameter against |
- ocracy.translation.make_kwargs_translator(param_map, *, on_unsupported='warn')[source]#
Create a function that translates normalized kwargs to native kwargs.
- Parameters:
param_map (
Dict[str,Optional[dict]]) – Mapping ofnormalized_name -> spec; seeocracy.kit.translationfor every spec form (Nonemeans the backend does not support the parameter).on_unsupported (
str) –"warn"(default),"raise","note"or"ignore". The notes are discarded by this dict-returning form.
- Return type:
- Returns:
A
translate(**kwargs) -> dictfunction.