summaryrefslogtreecommitdiffstats
path: root/parsers/QMs.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-03-18 03:03:06 +0000
committerPhilip Sargent <philip.sargent@gmail.com>2023-03-18 03:03:06 +0000
commit5a90e7b727bd224bea05bbdafe7031c3f4356dc0 (patch)
tree2cccff99a8974de069e078895980dce3bb633ec8 /parsers/QMs.py
parentd64948749e2f963f1938016764ce8256efd796dd (diff)
downloadtroggle-5a90e7b727bd224bea05bbdafe7031c3f4356dc0.tar.gz
troggle-5a90e7b727bd224bea05bbdafe7031c3f4356dc0.tar.bz2
troggle-5a90e7b727bd224bea05bbdafe7031c3f4356dc0.zip
fix more twiddly variations of QMs
Diffstat (limited to 'parsers/QMs.py')
-rw-r--r--parsers/QMs.py22
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/"),