@@ -29,10 +29,10 @@ class Metadata(Expando): | |||||
""" | """ | ||||
Updates the metadata with new stuff | Updates the metadata with new stuff | ||||
""" | """ | ||||
if isinstance(data, dict): | |||||
super(Metadata, self).update(data) | |||||
else: | |||||
if isinstance(data, basestring): | |||||
super(Metadata, self).update(yaml.load(data)) | super(Metadata, self).update(yaml.load(data)) | ||||
else: | |||||
super(Metadata, self).update(data) | |||||
class MetaPlugin(Plugin): | class MetaPlugin(Plugin): | ||||
@@ -18,8 +18,11 @@ class Expando(object): | |||||
Updates the expando with a new dictionary | Updates the expando with a new dictionary | ||||
""" | """ | ||||
d = d or {} | d = d or {} | ||||
for key, value in d.items(): | |||||
setattr(self, key, Expando.transform(value)) | |||||
if isinstance(d, dict): | |||||
for key, value in d.items(): | |||||
setattr(self, key, Expando.transform(value)) | |||||
elif isinstance(d, Expando): | |||||
self.update(d.__dict__) | |||||
@staticmethod | @staticmethod | ||||
def transform(primitive): | def transform(primitive): | ||||
@@ -37,6 +37,11 @@ def test_expando_update(): | |||||
assert x.b.c == d['b']['c'] | assert x.b.c == d['b']['c'] | ||||
assert x.b.d.e == d['b']['d']['e'] | assert x.b.d.e == d['b']['d']['e'] | ||||
assert x.f == d["f"] | assert x.f == d["f"] | ||||
d2 = {"a": 789, "f": "opq"} | |||||
y = Expando(d2) | |||||
x.update(y) | |||||
assert x.a == 789 | |||||
assert x.f == "opq" | |||||
TEST_SITE_ROOT = File(__file__).parent.child_folder('sites/test_jinja') | TEST_SITE_ROOT = File(__file__).parent.child_folder('sites/test_jinja') | ||||
import yaml | import yaml | ||||