2 Nominatim configuration accessor.
6 from dotenv import dotenv_values
9 """ Load and manage the project configuration.
11 Nominatim uses dotenv to configure the software. Configuration options
12 are resolved in the following order:
14 * from the OS environment
15 * from the .env file in the project directory of the installation
16 * from the default installation in the configuration directory
18 All Nominatim configuration options are prefixed with 'NOMINATIM_' to
19 avoid conflicts with other environment variables.
22 def __init__(self, project_dir, config_dir):
23 self._config = dotenv_values(str((config_dir / 'env.defaults').resolve()))
24 if project_dir is not None:
25 self._config.update(dotenv_values(str((project_dir / '.env').resolve())))
27 def __getattr__(self, name):
28 name = 'NOMINATIM_' + name
30 return os.environ.get(name) or self._config[name]
33 """ Return a copy of the OS environment with the Nominatim configuration
36 env = dict(self._config)
37 env.update(os.environ)