Skip to content

Commit

Permalink
Fix implicit and explicit keygroups issue in #4.
Browse files Browse the repository at this point in the history
Does everything look good @BurntSushi?
  • Loading branch information
uiri committed Mar 5, 2013
1 parent 8f2d857 commit fc5b03d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion toml.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime

def loads(s):
implicitgroups = []
"""Returns a dictionary containing s, a string, parsed as toml."""
retval = {}
currentlevel = retval
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit fc5b03d

Please sign in to comment.