X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/72b01148d2d12f71c12440c15fa078b55e1c8f86..8f2746fe24d51cab464960c2679da5b09e7da882:/nominatim/config.py diff --git a/nominatim/config.py b/nominatim/config.py index a22f90ab..72aaf0bd 100644 --- a/nominatim/config.py +++ b/nominatim/config.py @@ -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() @@ -30,7 +30,7 @@ class Configuration: self.project_dir = project_dir self.config_dir = config_dir self._config = dotenv_values(str((config_dir / 'env.defaults').resolve())) - if project_dir is not None: + if project_dir is not None and (project_dir / '.env').is_file(): self._config.update(dotenv_values(str((project_dir / '.env').resolve()))) # Add defaults for variables that are left empty to set the default. @@ -39,6 +39,16 @@ class Configuration: self._config['NOMINATIM_ADDRESS_LEVEL_CONFIG'] = \ str(config_dir / 'address-levels.json') + class _LibDirs: + 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