mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Update toml.py to upstream 1069d2449760525535ca77514a92e9237ee0deaf
This commit is contained in:
parent
f6941b35e3
commit
38ccbe61ae
1 changed files with 7 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
||||||
import datetime, decimal
|
import datetime, decimal, re
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_range = xrange
|
_range = xrange
|
||||||
|
@ -42,7 +42,7 @@ def loads(s):
|
||||||
sl = list(s)
|
sl = list(s)
|
||||||
openarr = 0
|
openarr = 0
|
||||||
openstring = False
|
openstring = False
|
||||||
arrayoftables = True
|
arrayoftables = False
|
||||||
beginline = True
|
beginline = True
|
||||||
keygroup = False
|
keygroup = False
|
||||||
delnum = 1
|
delnum = 1
|
||||||
|
@ -79,7 +79,7 @@ def loads(s):
|
||||||
keygroup = True
|
keygroup = True
|
||||||
else:
|
else:
|
||||||
openarr += 1
|
openarr += 1
|
||||||
if sl[i] == ']' and not openstring and not keygroup and not arrayoftables:
|
if sl[i] == ']' and not openstring:
|
||||||
if keygroup:
|
if keygroup:
|
||||||
keygroup = False
|
keygroup = False
|
||||||
elif arrayoftables:
|
elif arrayoftables:
|
||||||
|
@ -251,10 +251,10 @@ def load_value(v):
|
||||||
newv += unicode(hx[len(hxb):])
|
newv += unicode(hx[len(hxb):])
|
||||||
v = newv
|
v = newv
|
||||||
for i in range(len(escapes)):
|
for i in range(len(escapes)):
|
||||||
v = v.replace("\\"+escapes[i], escapedchars[i])
|
if escapes[i] == '\\':
|
||||||
# (where (n) signifies a member of escapes:
|
v = v.replace("\\"+escapes[i], escapedchars[i])
|
||||||
# undo (\\)(\\)(n) -> (\\)(\n)
|
else:
|
||||||
v = v.replace("\\"+escapedchars[i], "\\\\"+escapes[i])
|
v = re.sub("([^\\\\](\\\\\\\\)*)\\\\"+escapes[i], "\\1"+escapedchars[i], v)
|
||||||
return (v[1:-1], "str")
|
return (v[1:-1], "str")
|
||||||
elif v[0] == '[':
|
elif v[0] == '[':
|
||||||
return (load_array(v), "array")
|
return (load_array(v), "array")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue