X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/c9035594152ac7caa5fd06b1334b031a39ce5ab3..474aea61da51df47cfb5b3cc8f4fdff9b0cf23fc:/src/nominatim_db/clicmd/api.py?ds=sidebyside diff --git a/src/nominatim_db/clicmd/api.py b/src/nominatim_db/clicmd/api.py index 7d9569e3..fac88bdd 100644 --- a/src/nominatim_db/clicmd/api.py +++ b/src/nominatim_db/clicmd/api.py @@ -7,17 +7,19 @@ """ Subcommand definitions for API calls from the command line. """ -from typing import Dict, Any +from typing import Dict, Any, Optional import argparse import logging import json import sys +from functools import reduce import nominatim_api as napi import nominatim_api.v1 as api_output from nominatim_api.v1.helpers import zoom_to_rank, deduplicate_results from nominatim_api.v1.format import dispatch as formatting import nominatim_api.logging as loglib +from ..errors import UsageError from .args import NominatimArgs # Do not repeat documentation of subcommand classes. @@ -61,7 +63,7 @@ def _add_api_output_arguments(parser: argparse.ArgumentParser) -> None: "Parameter is difference tolerance in degrees.")) -def _get_geometry_output(args) -> napi.GeometryFormat: +def _get_geometry_output(args: NominatimArgs) -> napi.GeometryFormat: """ Get the requested geometry output format in a API-compatible format. """ @@ -82,7 +84,7 @@ def _get_geometry_output(args) -> napi.GeometryFormat: raise UsageError(f"Unknown polygon output format '{args.polygon_output}'.") from exp -def _get_locales(args, default: Optional[str]) -> napi.Locales: +def _get_locales(args: NominatimArgs, default: Optional[str]) -> napi.Locales: """ Get the locales from the language parameter. """ if args.lang: @@ -93,7 +95,7 @@ def _get_locales(args, default: Optional[str]) -> napi.Locales: return napi.Locales() -def _get_layers(args, default: napi.DataLayer) -> Optional[napi.DataLayer]: +def _get_layers(args: NominatimArgs, default: napi.DataLayer) -> Optional[napi.DataLayer]: """ Get the list of selected layers as a DataLayer enum. """ if not args.layers: