X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/dfcb24061eb6d3d415cd86d2f4edd95c4debaf36..6e688a01138dd18c643cf3a5e3541506d9f63b20:/nominatim/api/result_formatting.py?ds=inline diff --git a/nominatim/api/result_formatting.py b/nominatim/api/result_formatting.py index 09cf7db8..4670a1d6 100644 --- a/nominatim/api/result_formatting.py +++ b/nominatim/api/result_formatting.py @@ -5,13 +5,13 @@ # Copyright (C) 2023 by the Nominatim developer community. # For a full list of authors see the git log. """ -Helper classes and functions for formating results into API responses. +Helper classes and functions for formatting results into API responses. """ -from typing import Type, TypeVar, Dict, List, Callable, Any +from typing import Type, TypeVar, Dict, List, Callable, Any, Mapping from collections import defaultdict T = TypeVar('T') # pylint: disable=invalid-name -FormatFunc = Callable[[T], str] +FormatFunc = Callable[[T, Mapping[str, Any]], str] class FormatDispatcher: @@ -47,10 +47,10 @@ class FormatDispatcher: return fmt in self.format_functions[result_type] - def format_result(self, result: Any, fmt: str) -> str: + def format_result(self, result: Any, fmt: str, options: Mapping[str, Any]) -> str: """ Convert the given result into a string using the given format. The format is expected to be in the list returned by `list_formats()`. """ - return self.format_functions[type(result)][fmt](result) + return self.format_functions[type(result)][fmt](result, options)