]> git.openstreetmap.org Git - nominatim.git/commitdiff
add library directories to config
authorSarah Hoffmann <lonvia@denofr.de>
Mon, 19 Apr 2021 07:06:42 +0000 (09:06 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 19 Apr 2021 08:26:25 +0000 (10:26 +0200)
Allows to reduce the number of parameters in functions that take
the config anyway.

nominatim/cli.py
nominatim/config.py

index d560676e0170e16a79700d459e440c282f4eafd4..47b25c17862bc3a3fb2843ab79b04a07a3180b7e 100644 (file)
@@ -84,6 +84,11 @@ class CommandlineParser:
 
         args.config = Configuration(args.project_dir, args.config_dir,
                                     environ=kwargs.get('environ', os.environ))
+        args.config.set_libdirs(module=args.module_dir,
+                                osm2pgsql=args.osm2pgsql_path,
+                                php=args.phplib_dir,
+                                sql=args.sqllib_dir,
+                                data=args.data_dir)
 
         log = logging.getLogger()
         log.warning('Using project directory: %s', str(args.project_dir))
index d4645b93b89b08ee0eecab7818f0bc94ce652210..d1df17b726bac3db70d7c8a788c98a9abbf4401b 100644 (file)
@@ -39,6 +39,16 @@ class Configuration:
             self._config['NOMINATIM_ADDRESS_LEVEL_CONFIG'] = \
                 str(config_dir / 'address-levels.json')
 
+        class _LibDirs: # pylint: disable=too-few-public-methods
+            pass
+
+        self.lib_dir = _LibDirs()
+
+    def set_libdirs(self, **kwargs):
+        """ Set paths to library functions and data.
+        """
+        for key, value in kwargs.items():
+            setattr(self.lib_dir, key, Path(value).resolve())
 
     def __getattr__(self, name):
         name = 'NOMINATIM_' + name