Mercurial > piecrust2
comparison 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 |
comparison
equal
deleted
inserted
replaced
1097:2b2eaee96121 | 1098:2323f0788170 |
---|---|
416 "list.") | 416 "list.") |
417 | 417 |
418 # Check routes are referencing correct sources, have default | 418 # Check routes are referencing correct sources, have default |
419 # values, etc. | 419 # values, etc. |
420 used_sources = set() | 420 used_sources = set() |
421 existing_sources = set(values['site']['sources'].keys()) | 421 source_configs = values['site']['sources'] |
422 existing_sources = set(source_configs.keys()) | |
422 for rc in v: | 423 for rc in v: |
423 if not isinstance(rc, dict): | 424 if not isinstance(rc, dict): |
424 raise ConfigurationError("All routes in 'site/routes' must be " | 425 raise ConfigurationError("All routes in 'site/routes' must be " |
425 "dictionaries.") | 426 "dictionaries.") |
426 rc_url = rc.get('url') | 427 rc_url = rc.get('url') |
442 used_sources.add(r_source) | 443 used_sources.add(r_source) |
443 | 444 |
444 rc.setdefault('pass', 1) | 445 rc.setdefault('pass', 1) |
445 rc.setdefault('page_suffix', '/%num%') | 446 rc.setdefault('page_suffix', '/%num%') |
446 | 447 |
448 # Raise errors about non-asset sources that have no URL routes. | |
449 sources_with_no_route = list(filter( | |
450 lambda s: source_configs[s].get('pipeline') != 'asset', | |
451 existing_sources.difference(used_sources))) | |
452 if sources_with_no_route: | |
453 raise ConfigurationError( | |
454 "The following sources have no routes: %s" % | |
455 ', '.join(sources_with_no_route)) | |
456 | |
447 return v | 457 return v |
448 | 458 |
449 | 459 |
450 def _validate_site_taxonomies(v, values, cache): | 460 def _validate_site_taxonomies(v, values, cache): |
451 if not isinstance(v, dict): | 461 if not isinstance(v, dict): |