X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/6e89310a9285f1ad15d8002bf68f578eada367a0..f76dbb0a167fa49839c30da1a4e1d15439070e2a:/src/nominatim_db/clicmd/args.py diff --git a/src/nominatim_db/clicmd/args.py b/src/nominatim_db/clicmd/args.py index ab93863d..a8ff210a 100644 --- a/src/nominatim_db/clicmd/args.py +++ b/src/nominatim_db/clicmd/args.py @@ -10,16 +10,16 @@ Provides custom functions over command-line arguments. from typing import Optional, List, Dict, Any, Sequence, Tuple import argparse import logging -from functools import reduce from pathlib import Path -from nominatim_core.errors import UsageError -from nominatim_core.config import Configuration -from nominatim_core.typing import Protocol -import nominatim_api as napi +from ..errors import UsageError +from ..config import Configuration +from ..typing import Protocol + LOG = logging.getLogger() + class Subcommand(Protocol): """ Interface to be implemented by classes implementing a CLI subcommand. @@ -139,6 +139,7 @@ class NominatimArgs: # Arguments to all query functions format: str + list_formats: bool addressdetails: bool extratags: bool namedetails: bool @@ -179,7 +180,6 @@ class NominatimArgs: polygon_geojson: bool group_hierarchy: bool - def osm2pgsql_options(self, default_cache: int, default_threads: int) -> Dict[str, Any]: """ Return the standard osm2pgsql options that can be derived @@ -189,7 +189,7 @@ class NominatimArgs: return dict(osm2pgsql=self.config.OSM2PGSQL_BINARY or self.config.lib_dir.osm2pgsql, osm2pgsql_cache=self.osm2pgsql_cache or default_cache, osm2pgsql_style=self.config.get_import_style_file(), - osm2pgsql_style_path=self.config.config_dir, + osm2pgsql_style_path=self.config.lib_dir.lua, threads=self.threads or default_threads, dsn=self.config.get_libpq_dsn(), flatnode_file=str(self.config.get_path('FLATNODE_FILE') or ''), @@ -197,9 +197,8 @@ class NominatimArgs: slim_index=self.config.TABLESPACE_OSM_INDEX, main_data=self.config.TABLESPACE_PLACE_DATA, main_index=self.config.TABLESPACE_PLACE_INDEX - ) - ) - + ) + ) def get_osm_file_list(self) -> Optional[List[Path]]: """ Return the --osm-file argument as a list of Paths or None @@ -216,45 +215,3 @@ class NominatimArgs: raise UsageError('Cannot access file.') return files - - - def get_geometry_output(self) -> napi.GeometryFormat: - """ Get the requested geometry output format in a API-compatible - format. - """ - if not self.polygon_output: - return napi.GeometryFormat.NONE - if self.polygon_output == 'geojson': - return napi.GeometryFormat.GEOJSON - if self.polygon_output == 'kml': - return napi.GeometryFormat.KML - if self.polygon_output == 'svg': - return napi.GeometryFormat.SVG - if self.polygon_output == 'text': - return napi.GeometryFormat.TEXT - - try: - return napi.GeometryFormat[self.polygon_output.upper()] - except KeyError as exp: - raise UsageError(f"Unknown polygon output format '{self.polygon_output}'.") from exp - - - def get_locales(self, default: Optional[str]) -> napi.Locales: - """ Get the locales from the language parameter. - """ - if self.lang: - return napi.Locales.from_accept_languages(self.lang) - if default: - return napi.Locales.from_accept_languages(default) - - return napi.Locales() - - - def get_layers(self, default: napi.DataLayer) -> Optional[napi.DataLayer]: - """ Get the list of selected layers as a DataLayer enum. - """ - if not self.layers: - return default - - return reduce(napi.DataLayer.__or__, - (napi.DataLayer[s.upper()] for s in self.layers))