X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/507fdd4f40ea9a7fe77b90847d8e6e90a3cbbbd0..109af0ef1c55421a166fd2d45586d04fe7f6f969:/nominatim/config.py diff --git a/nominatim/config.py b/nominatim/config.py index 66375f6c..bc3556f3 100644 --- a/nominatim/config.py +++ b/nominatim/config.py @@ -93,6 +93,23 @@ class Configuration: raise UsageError("Configuration error.") from exp + def get_path(self, name): + """ Return the given configuration parameter as a Path. + If a relative path is configured, then the function converts this + into an absolute path with the project directory as root path. + If the configuration is unset, a falsy value is returned. + """ + value = self.__getattr__(name) + if value: + value = Path(value) + + if not value.is_absolute(): + value = self.project_dir / value + + value = value.resolve() + + return value + def get_libpq_dsn(self): """ Get configured database DSN converted into the key/value format understood by libpq and psycopg.