make formatting module non-static

This commit is contained in:
Sarah Hoffmann
2024-08-13 22:39:43 +02:00
parent 4e0602919c
commit 0c25e80be0
5 changed files with 37 additions and 14 deletions

View File

@@ -14,6 +14,7 @@ import math
from ..config import Configuration
from .. import logging as loglib
from ..core import NominatimAPIAsync
from ..result_formatting import FormatDispatcher
CONTENT_TEXT = 'text/plain; charset=utf-8'
CONTENT_XML = 'text/xml; charset=utf-8'
@@ -28,6 +29,7 @@ class ASGIAdaptor(abc.ABC):
"""
content_type: str = CONTENT_TEXT
@abc.abstractmethod
def get(self, name: str, default: Optional[str] = None) -> Optional[str]:
""" Return an input parameter as a string. If the parameter was
@@ -60,6 +62,7 @@ class ASGIAdaptor(abc.ABC):
body of the response to 'output'.
"""
@abc.abstractmethod
def base_uri(self) -> str:
""" Return the URI of the original request.
@@ -72,6 +75,12 @@ class ASGIAdaptor(abc.ABC):
"""
@abc.abstractmethod
def formatting(self) -> FormatDispatcher:
""" Return the formatting object to use.
"""
def get_int(self, name: str, default: Optional[int] = None) -> int:
""" Return an input parameter as an int. Raises an exception if
the parameter is given but not in an integer format.