From d6ee94bf79e534093e3ffb262d4d23e75180f0ca Mon Sep 17 00:00:00 2001 From: Wookey Date: Wed, 19 Jun 2013 03:35:59 +0100 Subject: [PATCH] Use verbose option for regex to lay it out with comments so not utterly cryptic --- .../make-prospectingguide-new.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/noinfo/prospecting_guide_scripts/make-prospectingguide-new.py b/noinfo/prospecting_guide_scripts/make-prospectingguide-new.py index 1d03119ca..8b3a4a03e 100644 --- a/noinfo/prospecting_guide_scripts/make-prospectingguide-new.py +++ b/noinfo/prospecting_guide_scripts/make-prospectingguide-new.py @@ -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