From fc5b03d2ccf342b0eb0f74fa951f0614c4aabf2d Mon Sep 17 00:00:00 2001 From: Uiri Date: Tue, 5 Mar 2013 16:28:19 -0500 Subject: [PATCH] Fix implicit and explicit keygroups issue in #4. Does everything look good @BurntSushi? --- toml.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/toml.py b/toml.py index bcbb085..c65c0cc 100644 --- a/toml.py +++ b/toml.py @@ -1,6 +1,7 @@ import datetime def loads(s): + implicitgroups = [] """Returns a dictionary containing s, a string, parsed as toml.""" retval = {} currentlevel = retval @@ -65,8 +66,13 @@ def loads(s): try: currentlevel[group] if i == len(groups) - 1: - raise Exception("What? "+group+" already exists?"+str(currentlevel)) + if group in implicitgroups: + implicitgroups.remove(group) + else: + raise Exception("What? "+group+" already exists?"+str(currentlevel)) except KeyError: + if i != len(groups) - 1: + implicitgroups.append(group) currentlevel[group] = {} currentlevel = currentlevel[group] elif "=" in line: