diff options
Diffstat (limited to 'parsers')
-rw-r--r-- | parsers/QMs.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/parsers/QMs.py b/parsers/QMs.py index 5a0be79..56c97e4 100644 --- a/parsers/QMs.py +++ b/parsers/QMs.py @@ -147,20 +147,32 @@ def parse_KH_QMs(kh, inputFile, ticked): # <dt><a href="sibria.htm#qC1997-161-27" name="C1997-161-27">C1997-161-27</a> A<dd>Sib: pitch at end of Fuzzy Logic [Paradox Rift - continues] [sep.fuzzy.13] line += 1 res = re.search( - r"name=\"[CB](?P<year>\d*)-(?P<cave>\d*)-(?P<number>\d*).*</a>\s*(?P<grade>[ABCDX?V])<dd>(?P<location_description>.*)(\[(?P<station_name>.*)\])?", + r"name=\"[CB](?P<year>\d*)-(?P<cave>\d*)-(?P<number>\d*).*</a>\s*(?P<grade>[ABCDX?V])<dd>(?P<location_description>[^[]*)(\[\s*(?P<completion>[^]]*)\s*\])?\s*(\[\s*(?P<station_name>[^]]*)\s*\])?", dataline, ) if res: res = res.groupdict() year = int(res["year"]) + completion = res["completion"] + station_name = res["station_name"] + if not completion and station_name: + if station_name.startswith("<a href"): + completion = station_name + station_name = "" + if completion and not station_name: + if not ticked: + station_name = completion + + if completion: + completion = completion.replace("<a href=\"","<a href=\"/1623/161/") nearest_station_name = "" resolution_station_name = "" - if res["station_name"]: + if station_name: if ticked: - resolution_station_name = res["station_name"].replace("<a href=\"","<a href=\"/1623/161/") + resolution_station_name = station_name.replace("<a href=\"","<a href=\"/1623/161/") else: - nearest_station_name = res["station_name"] + nearest_station_name = station_name.replace("<a href=\"","<a href=\"/1623/161/") lookupAttribs = { #'found_by':placeholder, "blockname": "", @@ -172,7 +184,7 @@ def parse_KH_QMs(kh, inputFile, ticked): nonLookupAttribs = { "ticked": ticked, "page_ref": "", - "completion_description": "", + "completion_description": completion, "nearest_station_name": nearest_station_name, "resolution_station_name": resolution_station_name, "location_description": res["location_description"].replace("<a href=\"","<a href=\"/1623/161/"), |