diff piecrust/configuration.py @ 3:f485ba500df3

Gigantic change to basically make PieCrust 2 vaguely functional. - Serving works, with debug window. - Baking works, multi-threading, with dependency handling. - Various things not implemented yet.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 10 Aug 2014 23:43:16 -0700
parents 40fa08b261b9
children 474c9882decf
line wrap: on
line diff
--- a/piecrust/configuration.py	Wed Dec 25 22:16:46 2013 -0800
+++ b/piecrust/configuration.py	Sun Aug 10 23:43:16 2014 -0700
@@ -6,18 +6,25 @@
 logger = logging.getLogger(__name__)
 
 
+class ConfigurationError(Exception):
+    pass
+
+
 class Configuration(object):
     def __init__(self, values=None, validate=True):
         if values is not None:
-            self.set_all(values, validate)
+            self.setAll(values, validate)
         else:
             self._values = None
 
-    def set_all(self, values, validate=True):
+    def setAll(self, values, validate=True):
         if validate:
             self._validateAll(values)
         self._values = values
 
+    def getAll(self):
+        return self.get()
+
     def get(self, key_path=None):
         self._ensureLoaded()
         if key_path is None:
@@ -73,10 +80,12 @@
         return value
 
 
-def merge_dicts(source, merging, validator=None):
+def merge_dicts(source, merging, validator=None, *args):
     if validator is None:
         validator = lambda k, v: v
     _recurse_merge_dicts(source, merging, None, validator)
+    for other in args:
+        _recurse_merge_dicts(source, other, None, validator)
 
 
 def _recurse_merge_dicts(local_cur, incoming_cur, parent_path, validator):
@@ -105,7 +114,7 @@
     m = header_regex.match(text)
     if m is not None:
         header = unicode(m.group('header'))
-        config = yaml.safe_load(header)
+        config = yaml.load(header, Loader=yaml.BaseLoader)
         offset = m.end()
     else:
         config = {}