From 8f2d85710d0fccc6f495968b6e5ad551ab923c41 Mon Sep 17 00:00:00 2001 From: Uiri Date: Tue, 5 Mar 2013 11:54:44 -0500 Subject: [PATCH] Allow [ and # and = in key names as per #4 --- toml.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/toml.py b/toml.py index 79638f3..bcbb085 100644 --- a/toml.py +++ b/toml.py @@ -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: @@ -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 =")