diff piecrust/app.py @ 466:456db44dcc53

bake: Pass the config variants and values from the CLI to the baker. TODO: add support for that for the processor pipeline.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 11 Jul 2015 23:51:02 -0700
parents 6801ad5aa1d4
children 5ee62af2a4e3
line wrap: on
line diff
--- a/piecrust/app.py	Sat Jul 11 20:33:55 2015 -0700
+++ b/piecrust/app.py	Sat Jul 11 23:51:02 2015 -0700
@@ -607,3 +607,14 @@
 
         return dirs
 
+
+def apply_variant_and_values(app, config_variant=None, config_values=None):
+    if config_variant is not None:
+        logger.debug("Applying configuration variant '%s'." % config_variant)
+        app.config.applyVariant('variants/' + config_variant)
+
+    if config_values is not None:
+        for name, value in config_values:
+            logger.debug("Setting configuration '%s' to: %s" % (name, value))
+            app.config.set(name, value)
+