diff piecrust/appconfig.py @ 1098:2323f0788170

config: Report error if a non-asset source has no URL route.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 17 Feb 2018 11:52:31 -0800
parents 45ad976712ec
children 97b1b46cc156
line wrap: on
line diff
--- a/piecrust/appconfig.py	Sat Feb 17 11:51:45 2018 -0800
+++ b/piecrust/appconfig.py	Sat Feb 17 11:52:31 2018 -0800
@@ -418,7 +418,8 @@
     # Check routes are referencing correct sources, have default
     # values, etc.
     used_sources = set()
-    existing_sources = set(values['site']['sources'].keys())
+    source_configs = values['site']['sources']
+    existing_sources = set(source_configs.keys())
     for rc in v:
         if not isinstance(rc, dict):
             raise ConfigurationError("All routes in 'site/routes' must be "
@@ -444,6 +445,15 @@
         rc.setdefault('pass', 1)
         rc.setdefault('page_suffix', '/%num%')
 
+    # Raise errors about non-asset sources that have no URL routes.
+    sources_with_no_route = list(filter(
+        lambda s: source_configs[s].get('pipeline') != 'asset',
+        existing_sources.difference(used_sources)))
+    if sources_with_no_route:
+        raise ConfigurationError(
+            "The following sources have no routes: %s" %
+            ', '.join(sources_with_no_route))
+
     return v