]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/config.py
fix regression with lat/lon in json output
[nominatim.git] / nominatim / config.py
index 1728c291e92fadec129f8a531247165dbea688ee..3a4c3a6bed038ec9bb03f27eeb90979fbf675ca9 100644 (file)
@@ -17,6 +17,7 @@ import json
 import yaml
 
 from dotenv import dotenv_values
+from psycopg2.extensions import parse_dsn
 
 from nominatim.typing import StrPath
 from nominatim.errors import UsageError
@@ -51,7 +52,7 @@ class Configuration:
         Nominatim uses dotenv to configure the software. Configuration options
         are resolved in the following order:
 
-         * from the OS environment (or the dirctionary given in `environ`
+         * from the OS environment (or the dictionary given in `environ`)
          * from the .env file in the project directory of the installation
          * from the default installation in the configuration directory
 
@@ -164,6 +165,18 @@ class Configuration:
         return dsn
 
 
+    def get_database_params(self) -> Mapping[str, str]:
+        """ Get the configured parameters for the database connection
+            as a mapping.
+        """
+        dsn = self.DATABASE_DSN
+
+        if dsn.startswith('pgsql:'):
+            return dict((p.split('=', 1) for p in dsn[6:].split(';')))
+
+        return parse_dsn(dsn)
+
+
     def get_import_style_file(self) -> Path:
         """ Return the import style file as a path object. Translates the
             name of the standard styles automatically into a file in the
@@ -172,7 +185,7 @@ class Configuration:
         style = getattr(self, 'IMPORT_STYLE')
 
         if style in ('admin', 'street', 'address', 'full', 'extratags'):
-            return self.config_dir / f'import-{style}.style'
+            return self.config_dir / f'import-{style}.lua'
 
         return self.find_config_file('', 'IMPORT_STYLE')