]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/config.py
rename manual directory to man
[nominatim.git] / nominatim / config.py
index 5d56d024660752359c9a6eec71dae455ad7bc4cf..f316280bb42bf1dfc71bb5b1e16704bbdfcafa5c 100644 (file)
@@ -12,6 +12,27 @@ from nominatim.errors import UsageError
 
 LOG = logging.getLogger()
 
+
+def flatten_config_list(content, section=''):
+    """ Flatten YAML configuration lists that contain include sections
+        which are lists themselves.
+    """
+    if not content:
+        return []
+
+    if not isinstance(content, list):
+        raise UsageError(f"List expected in section '{section}'.")
+
+    output = []
+    for ele in content:
+        if isinstance(ele, list):
+            output.extend(flatten_config_list(ele, section))
+        else:
+            output.append(ele)
+
+    return output
+
+
 class Configuration:
     """ Load and manage the project configuration.
 
@@ -172,7 +193,7 @@ class Configuration:
 
         search_paths = [self.project_dir, self.config_dir]
         for path in search_paths:
-            if (path / filename).is_file():
+            if path is not None and (path / filename).is_file():
                 return path / filename
 
         LOG.fatal("Configuration file '%s' not found.\nDirectories searched: %s",