mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
split up large setup function
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
"""
|
||||
Provides custom functions over command-line arguments.
|
||||
"""
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from nominatim.errors import UsageError
|
||||
|
||||
LOG = logging.getLogger()
|
||||
|
||||
class NominatimArgs:
|
||||
""" Customized namespace class for the nominatim command line tool
|
||||
@@ -25,3 +30,20 @@ class NominatimArgs:
|
||||
main_index=self.config.TABLESPACE_PLACE_INDEX
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def get_osm_file_list(self):
|
||||
""" Return the --osm-file argument as a list of Paths or None
|
||||
if no argument was given. The function also checks if the files
|
||||
exist and raises a UsageError if one cannot be found.
|
||||
"""
|
||||
if not self.osm_file:
|
||||
return None
|
||||
|
||||
files = [Path(f) for f in self.osm_file]
|
||||
for fname in files:
|
||||
if not fname.is_file():
|
||||
LOG.fatal("OSM file '%s' does not exist.", fname)
|
||||
raise UsageError('Cannot access file.')
|
||||
|
||||
return files
|
||||
|
||||
Reference in New Issue
Block a user