translator_directory.utils ========================== .. py:module:: translator_directory.utils Functions --------- .. autoapisummary:: translator_directory.utils.to_tuple translator_directory.utils.found_route translator_directory.utils.out_of_tolerance translator_directory.utils.validate_geocode_result translator_directory.utils.parse_directions_result translator_directory.utils.same_coords translator_directory.utils.update_drive_distances translator_directory.utils.geocode_translator_addresses translator_directory.utils.nationality_choices translator_directory.utils.country_code_to_name translator_directory.utils.get_custom_text Module Contents --------------- .. py:function:: to_tuple(coordinate: onegov.gis.models.coordinates.RealCoordinates) -> tuple[float, float] .. py:function:: found_route(response: requests.Response) -> bool .. py:function:: out_of_tolerance(old_distance: float | None, new_distance: float | None, tolerance_factor: float, max_tolerance: float | None = None) -> bool Checks if distances are off by +- a factor, but returns False if a set max_tolerance is not exceeded. .. py:function:: validate_geocode_result(response: requests.Response, zip_code: str | int | None, zoom: int | None = None, bbox: collections.abc.Collection[onegov.gis.models.coordinates.RealCoordinates] | None = None) -> onegov.gis.models.coordinates.RealCoordinates | None .. py:function:: parse_directions_result(response: requests.Response) -> float .. py:function:: same_coords(this: onegov.gis.Coordinates, other: onegov.gis.Coordinates) -> bool .. py:function:: update_drive_distances(request: onegov.translator_directory.request.TranslatorAppRequest, only_empty: bool, tolerance_factor: float = 0.1, max_tolerance: float | None = None, max_distance: float | None = None) -> tuple[int, int, int, list[onegov.translator_directory.models.translator.Translator], list[tuple[onegov.translator_directory.models.translator.Translator, float]]] Handles updating Translator.driving_distance. Can be used in a cli or view. .. py:function:: geocode_translator_addresses(request: onegov.translator_directory.request.TranslatorAppRequest, only_empty: bool, bbox: collections.abc.Collection[onegov.gis.models.coordinates.RealCoordinates] | None = None) -> tuple[int, int, int, int, list[onegov.translator_directory.models.translator.Translator]] .. py:function:: nationality_choices(locale: str | None) -> list[wtforms.fields.choices._Choice] .. py:function:: country_code_to_name(locale: str | None) -> dict[str, str] Returns a dict of country codes mapped to its country names according the given locale. Example: {'CH': 'Switzerland', 'DE': 'Germany, ...} .. py:function:: get_custom_text(request: onegov.org.request.OrgRequest, key: str) -> str Returns a custom text from the app's custom_texts dict.