]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/config.py
Merge pull request #2284 from lonvia/cleanup-word-frequency-computation
[nominatim.git] / nominatim / config.py
index 564884f612a40d97eed89cff157abdc77d8008f8..d1df17b726bac3db70d7c8a788c98a9abbf4401b 100644 (file)
@@ -7,7 +7,7 @@ from pathlib import Path
 
 from dotenv import dotenv_values
 
-from .errors import UsageError
+from nominatim.errors import UsageError
 
 LOG = logging.getLogger()
 
@@ -25,8 +25,8 @@ class Configuration:
         avoid conflicts with other environment variables.
     """
 
-    def __init__(self, project_dir, config_dir, environ=os.environ):
-        self.environ = environ
+    def __init__(self, project_dir, config_dir, environ=None):
+        self.environ = environ or os.environ
         self.project_dir = project_dir
         self.config_dir = config_dir
         self._config = dotenv_values(str((config_dir / 'env.defaults').resolve()))
@@ -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