TrayLayout: Give more descriptive parse errors
Also allow both X and now also x for removed floor
This commit is contained in:
parent
7397e49b2b
commit
7355d0d612
|
@ -360,7 +360,7 @@ You can replace the space characters representing the floor by a "X" to remove t
|
||||||
hwalls = []
|
hwalls = []
|
||||||
vwalls = []
|
vwalls = []
|
||||||
floors = []
|
floors = []
|
||||||
for line in input:
|
for nr, line in enumerate(input):
|
||||||
if not line or line[0] == "#":
|
if not line or line[0] == "#":
|
||||||
continue
|
continue
|
||||||
m = re.match(r"( \|)* ,>\s*(\d*\.?\d+)\s*mm\s*", line)
|
m = re.match(r"( \|)* ,>\s*(\d*\.?\d+)\s*mm\s*", line)
|
||||||
|
@ -389,25 +389,25 @@ You can replace the space characters representing the floor by a "X" to remove t
|
||||||
f = []
|
f = []
|
||||||
for n, c in enumerate(line[:len(x) * 2 + 1]):
|
for n, c in enumerate(line[:len(x) * 2 + 1]):
|
||||||
if n % 2:
|
if n % 2:
|
||||||
if c == 'X':
|
if c in 'xX':
|
||||||
f.append(False)
|
f.append(False)
|
||||||
elif c == ' ':
|
elif c == ' ':
|
||||||
f.append(True)
|
f.append(True)
|
||||||
else:
|
else:
|
||||||
raise ValueError(line)
|
raise ValueError('''Can't parse line %i in layout: expected " ", "x" or "X" for char #%i''' % (nr+1, n+1))
|
||||||
else:
|
else:
|
||||||
if c == ' ':
|
if c == ' ':
|
||||||
w.append(False)
|
w.append(False)
|
||||||
elif c == '|':
|
elif c == '|':
|
||||||
w.append(True)
|
w.append(True)
|
||||||
else:
|
else:
|
||||||
raise ValueError(line)
|
raise ValueError('''Can't parse line %i in layout: expected " ", or "|" for char #%i''' % (nr+1, n+1))
|
||||||
|
|
||||||
floors.append(f)
|
floors.append(f)
|
||||||
vwalls.append(w)
|
vwalls.append(w)
|
||||||
m = re.match(r"([ |][ X])+[ |]\s*(\d*\.?\d+)\s*mm\s*", line)
|
m = re.match(r"([ |][ xX])+[ |]\s*(\d*\.?\d+)\s*mm\s*", line)
|
||||||
if not m:
|
if not m:
|
||||||
raise ValueError(line)
|
raise ValueError('''Can't parse line %i in layout: Can read height of the row''' % (nr+1))
|
||||||
else:
|
else:
|
||||||
y.append(float(m.group(2)))
|
y.append(float(m.group(2)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue