2 Provides custom functions over command-line arguments.
 
   5 from pathlib import Path
 
   7 from nominatim.errors import UsageError
 
   9 LOG = logging.getLogger()
 
  12     """ Customized namespace class for the nominatim command line tool
 
  13         to receive the command-line arguments.
 
  16     def osm2pgsql_options(self, default_cache, default_threads):
 
  17         """ Return the standard osm2pgsql options that can be derived
 
  18             from the command line arguments. The resulting dict can be
 
  19             further customized and then used in `run_osm2pgsql()`.
 
  21         return dict(osm2pgsql=self.config.OSM2PGSQL_BINARY or self.osm2pgsql_path,
 
  22                     osm2pgsql_cache=self.osm2pgsql_cache or default_cache,
 
  23                     osm2pgsql_style=self.config.get_import_style_file(),
 
  24                     threads=self.threads or default_threads,
 
  25                     dsn=self.config.get_libpq_dsn(),
 
  26                     flatnode_file=self.config.FLATNODE_FILE,
 
  27                     tablespaces=dict(slim_data=self.config.TABLESPACE_OSM_DATA,
 
  28                                      slim_index=self.config.TABLESPACE_OSM_INDEX,
 
  29                                      main_data=self.config.TABLESPACE_PLACE_DATA,
 
  30                                      main_index=self.config.TABLESPACE_PLACE_INDEX
 
  35     def get_osm_file_list(self):
 
  36         """ Return the --osm-file argument as a list of Paths or None
 
  37             if no argument was given. The function also checks if the files
 
  38             exist and raises a UsageError if one cannot be found.
 
  43         files = [Path(f) for f in self.osm_file]
 
  45             if not fname.is_file():
 
  46                 LOG.fatal("OSM file '%s' does not exist.", fname)
 
  47                 raise UsageError('Cannot access file.')