Skip to content

Commit

Permalink
Allow [ and # and = in key names as per #4
Browse files Browse the repository at this point in the history
  • Loading branch information
uiri committed Mar 5, 2013
1 parent e9aae49 commit 8f2d857
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def loads(s):
sl.insert(j, ' ')
sl.pop(j+1)
j += 1
if sl[i] == '[' and not openstring:
if sl[i] == '[' and not openstring and not keygroup:
if beginline:
keygroup = True
else:
openarr += 1
if sl[i] == ']' and not openstring:
if sl[i] == ']' and not openstring and not keygroup:
if keygroup:
keygroup = False
else:
Expand Down Expand Up @@ -70,7 +70,16 @@ def loads(s):
currentlevel[group] = {}
currentlevel = currentlevel[group]
elif "=" in line:
pair = line.split('=', 1)
print line
i = 1
pair = line.split('=', i)
while pair[-2][-1] != ' ' and pair[-2][-1] != '\t':
i += 1
pair = line.split('=', i)
newpair = []
newpair.append('='.join(pair[:-1]))
newpair.append(pair[-1])
pair = newpair
if pair[0] == pair[0].rstrip():
print pair[0]
raise Exception("Missing whitespace between key name and =")
Expand Down

0 comments on commit 8f2d857

Please sign in to comment.