Use verbose option for regex to lay it out with comments so not

utterly cryptic
This commit is contained in:
Wookey
2013-06-19 03:35:59 +01:00
parent dca54300c4
commit d6ee94bf79

View File

@@ -345,8 +345,16 @@ for fnm in ("../all.3d", "../alltracks.3d"):
draw = draws[mapcode]
lastx, lasty = 0, 0
for l in file3d:
match = re.match(r'^(MOVE|LINE|NODE)\s+(-?[0-9.]+)\s+(-?[0-9.]+)\s+(-?[0-9.]+)(?:\s+\[(\S*)\])*(?:\s+(.*))*$', l)
#oldregex match = re.match(r'^(MOVE|LINE|NODE)\s+(-?[0-9.]+)\s+(-?[0-9.]+)\s+(-?[0-9.]+)\s+(?:[^[]*\[(.*)\] ?([^]]*)$)?', l)
match = re.match(r'''
^ #start
(MOVE|LINE|NODE) #command type
\s+(-?[0-9.]+) #X-co-ord
\s+(-?[0-9.]+) #Y-co-ord
\s+(-?[0-9.]+) #altitude
(?:\s+\[(\S*)\])* #node name inside []
(?:\s+(.*))* #all optional flags
$ #till the end of the line
''', l, re.VERBOSE)
if not match:
continue