Skip to content

Commit

Permalink
dotted keys with multiline strings, fix uiri#265
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelcolvin committed Jan 7, 2020
1 parent f4f0b84 commit 3ce7bae
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions toml/decoder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import io
from copy import deepcopy
from os import linesep
import re
import sys
Expand Down Expand Up @@ -360,6 +361,7 @@ def loads(s, _dict=dict, decoder=None):
" Reached end of file.", original, len(s))
s = ''.join(sl)
s = s.split('\n')
multilevel = None
multikey = None
multilinestr = ""
multibackslash = False
Expand Down Expand Up @@ -392,7 +394,8 @@ def loads(s, _dict=dict, decoder=None):
value, vtype = decoder.load_value(multilinestr)
except ValueError as err:
raise TomlDecodeError(str(err), original, pos)
currentlevel[multikey] = value
multilevel[multikey] = value
multilevel = None
multikey = None
multilinestr = ""
else:
Expand Down Expand Up @@ -504,12 +507,12 @@ def loads(s, _dict=dict, decoder=None):
raise TomlDecodeError(str(err), original, pos)
elif "=" in line:
try:
ret = decoder.load_line(line, currentlevel, multikey,
v_ = decoder.load_line(line, currentlevel, multikey,
multibackslash)
except ValueError as err:
raise TomlDecodeError(str(err), original, pos)
if ret is not None:
multikey, multilinestr, multibackslash = ret
if v_ is not None:
multilevel, multikey, multilinestr, multibackslash = v_
return retval


Expand Down Expand Up @@ -779,7 +782,7 @@ def load_line(self, line, currentlevel, multikey, multibackslash):
raise ValueError("Duplicate keys!")
except KeyError:
if multikey:
return multikey, multilinestr, multibackslash
return currentlevel, multikey, multilinestr, multibackslash
else:
currentlevel[pair[0]] = value

Expand Down

0 comments on commit 3ce7bae

Please sign in to comment.