Skip to content

Commit

Permalink
moving to dict object
Browse files Browse the repository at this point in the history
  • Loading branch information
nateprewitt authored and uiri committed Mar 30, 2017
1 parent 8f61c52 commit 87993ce
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def utcoffset(self, dt):
def dst(self, dt):
return datetime.timedelta(0)

class InlineTableDict(dict):
def __init__(self, *args):
dict.__init__(self, args)

try:
_range = xrange
except NameError:
Expand Down Expand Up @@ -548,7 +552,7 @@ def _load_value(v, strictly_valid=True):
elif v[0] == '[':
return (_load_array(v), "array")
elif v[0] == '{':
inline_object = {}
inline_object = InlineTableDict()
_load_inline_object(v, inline_object)
return (inline_object, "inline_object")
else:
Expand Down Expand Up @@ -742,7 +746,7 @@ def _dump_sections(o, sup, preserve=False):
if o[section] is not None:
retstr += (qsection + " = " +
str(_dump_value(o[section])) + '\n')
elif preserve:
elif preserve and isinstance(o[section], InlineTableDict):
retstr += (section + " = " + _dump_inline_table(o[section]))
else:
retdict[qsection] = o[section]
Expand Down

0 comments on commit 87993ce

Please sign in to comment.