From 89da661d25d10fd34f252e50b6c5753a496178ec Mon Sep 17 00:00:00 2001 From: Anthony Alba Date: Mon, 15 Jan 2018 09:05:17 +0800 Subject: [PATCH] from_dict: option to create root ConfigTree Addresses issue #137 --- pyhocon/config_parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyhocon/config_parser.py b/pyhocon/config_parser.py index 840d73ab..2f6ee583 100644 --- a/pyhocon/config_parser.py +++ b/pyhocon/config_parser.py @@ -94,7 +94,7 @@ def parse_string(content, basedir=None, resolve=True): return ConfigParser().parse(content, basedir, resolve) @classmethod - def from_dict(cls, dictionary): + def from_dict(cls, dictionary, root=False): """Convert dictionary (and ordered dictionary) into a ConfigTree :param dictionary: dictionary to convert :type dictionary: dict @@ -104,7 +104,7 @@ def from_dict(cls, dictionary): def create_tree(value): if isinstance(value, dict): - res = ConfigTree() + res = ConfigTree(root = root) for key, child_value in value.items(): res.put(key, create_tree(child_value)) return res