forked from expo/troggle
more QMs parsed correctly
This commit is contained in:
parent
7345e3a328
commit
d64948749e
@ -141,16 +141,26 @@ def parse_KH_QMs(kh, inputFile, ticked):
|
|||||||
with open(os.path.join(settings.EXPOWEB, inputFile), "r") as khQMfile:
|
with open(os.path.join(settings.EXPOWEB, inputFile), "r") as khQMfile:
|
||||||
khQMs = khQMfile.readlines()
|
khQMs = khQMfile.readlines()
|
||||||
nqms = 0
|
nqms = 0
|
||||||
for line in khQMs:
|
line = 0
|
||||||
|
fails = 0
|
||||||
|
for dataline in khQMs:
|
||||||
# <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]
|
# <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(
|
res = re.search(
|
||||||
r"name=\"[CB](?P<year>\d*)-(?P<cave>\d*)-(?P<number>\d*).*</a> (?P<grade>[ABCDX])<dd>(?P<location_description>.*)\[(?P<nearest_station_name>.*)\]",
|
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>.*)\])?",
|
||||||
line,
|
dataline,
|
||||||
)
|
)
|
||||||
if res:
|
if res:
|
||||||
res = res.groupdict()
|
res = res.groupdict()
|
||||||
year = int(res["year"])
|
year = int(res["year"])
|
||||||
|
|
||||||
|
nearest_station_name = ""
|
||||||
|
resolution_station_name = ""
|
||||||
|
if res["station_name"]:
|
||||||
|
if ticked:
|
||||||
|
resolution_station_name = res["station_name"].replace("<a href=\"","<a href=\"/1623/161/")
|
||||||
|
else:
|
||||||
|
nearest_station_name = res["station_name"]
|
||||||
lookupAttribs = {
|
lookupAttribs = {
|
||||||
#'found_by':placeholder,
|
#'found_by':placeholder,
|
||||||
"blockname": "",
|
"blockname": "",
|
||||||
@ -163,13 +173,20 @@ def parse_KH_QMs(kh, inputFile, ticked):
|
|||||||
"ticked": ticked,
|
"ticked": ticked,
|
||||||
"page_ref": "",
|
"page_ref": "",
|
||||||
"completion_description": "",
|
"completion_description": "",
|
||||||
"nearest_station_name": res["nearest_station_name"],
|
"nearest_station_name": nearest_station_name,
|
||||||
"location_description": res["location_description"],
|
"resolution_station_name": resolution_station_name,
|
||||||
|
"location_description": res["location_description"].replace("<a href=\"","<a href=\"/1623/161/"),
|
||||||
}
|
}
|
||||||
# Create new. We know it doesn't exist as we deleted evrything when we started.
|
# Create new. We know it doesn't exist as we deleted evrything when we started.
|
||||||
instance = QM.objects.create(**nonLookupAttribs, **lookupAttribs)
|
instance = QM.objects.create(**nonLookupAttribs, **lookupAttribs)
|
||||||
|
|
||||||
nqms += 1
|
nqms += 1
|
||||||
|
else:
|
||||||
|
if dataline.startswith("<dt><a href"):
|
||||||
|
fails += 1
|
||||||
|
message = f" ! - {inputFile} line {line} Parse error \n{str(dataline)} "
|
||||||
|
print(message)
|
||||||
|
DataIssue.objects.create(parser="QMs", message=message)
|
||||||
|
print(f" - {fails:2g} parsing errors in {inputFile}")
|
||||||
return nqms
|
return nqms
|
||||||
|
|
||||||
|
|
||||||
|
@ -1340,14 +1340,7 @@ class LoadingSurvex:
|
|||||||
else:
|
else:
|
||||||
qm_ticked = True
|
qm_ticked = True
|
||||||
# print(f"{survexblock.survexfile.cave} {survexblock}:{qm_no}{qm_grade} {qmline.group(4)}", file=sys.stderr)
|
# print(f"{survexblock.survexfile.cave} {survexblock}:{qm_no}{qm_grade} {qmline.group(4)}", file=sys.stderr)
|
||||||
if resolution_station_name:
|
|
||||||
qm_ticked = True
|
|
||||||
# if qmline.group(6) and qmline.group(6) != "-":
|
|
||||||
# resolution_station_name = qmline.group(6)
|
|
||||||
# if qmline.group(7):
|
|
||||||
# resolution_station_name = resolution_station_name + "." + qmline.group(7)
|
|
||||||
# else:
|
|
||||||
# resolution_station_name = ""
|
|
||||||
qm_notes = qmline.group(5)
|
qm_notes = qmline.group(5)
|
||||||
# qm_notes = qmline.group(8)
|
# qm_notes = qmline.group(8)
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<h3>Open leads</h3>
|
<h3>Open leads</h3>
|
||||||
<ul>{% for QM in cave.get_open_QMs %}
|
<ul>{% for QM in cave.get_open_QMs %}
|
||||||
<li><a href="{{QM.get_absolute_url}}">{{QM}}</a>
|
<li><a href="{{QM.get_absolute_url}}">{{QM}}</a>
|
||||||
{% if QM.nearest_station_name %}§<em>{{QM.nearest_station_name}}</em>§{% endif %}
|
{% if QM.nearest_station_name %}§<em>{{QM.nearest_station_name|safe}}</em>§{% endif %}
|
||||||
{{QM.location_description}} <b>{{QM.grade}}</b>
|
{{QM.location_description}} <b>{{QM.grade}}</b>
|
||||||
{% if QM.block %} <a href="/survexfile/{{QM.block.survexfile.path}}.svx">{{QM.block}}.svx</a> {{QM.block.date}} {% endif %}</li>
|
{% if QM.block %} <a href="/survexfile/{{QM.block.survexfile.path}}.svx">{{QM.block}}.svx</a> {{QM.block.date}} {% endif %}</li>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
@ -36,13 +36,13 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
§ QM.nearest_station_name<br />
|
§ QM.nearest_station_name<br />
|
||||||
☆ QM.resolution_station_name<br />
|
☆ QM.resolution_station_name - when ticked.<br />
|
||||||
<h3>Ticked off</h3>
|
<h3>Ticked off</h3>
|
||||||
<ul>{% for QM in cave.get_ticked_QMs %}
|
<ul>{% for QM in cave.get_ticked_QMs %}
|
||||||
<li><a href="{{QM.get_absolute_url}}">{{QM}}</a>
|
<li><a href="{{QM.get_absolute_url}}">{{QM}}</a>
|
||||||
{% if QM.nearest_station_name %}§<em>{{QM.nearest_station_name}}</em>§{% endif %}
|
{% if QM.nearest_station_name %}§<em>{{QM.nearest_station_name|safe}}</em>§{% endif %}
|
||||||
{% if QM.resolution_station_name %}☆<em>{{QM.resolution_station_name}}</em>☆{% endif %}
|
{% if QM.resolution_station_name %}<b>☆<em>{{QM.resolution_station_name|safe}}</em>☆</b>{% endif %}
|
||||||
{{QM.location_description}} <b>{{QM.grade}}</b>
|
{{QM.location_description|safe}} <b>{{QM.grade}}</b>
|
||||||
{% if QM.block %} <a href="/survexfile/{{QM.block.survexfile.path}}.svx">{{QM.block}}.svx</a> {{QM.block.date}} {% endif %}
|
{% if QM.block %} <a href="/survexfile/{{QM.block.survexfile.path}}.svx">{{QM.block}}.svx</a> {{QM.block.date}} {% endif %}
|
||||||
|
|
||||||
{% if QM.completion_description %}
|
{% if QM.completion_description %}
|
||||||
@ -57,5 +57,5 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
§ QM.nearest_station_name<br />
|
§ QM.nearest_station_name<br />
|
||||||
☆ QM.resolution_station_name<br />
|
☆ QM.resolution_station_name - when ticked.<br />
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -31,17 +31,18 @@ Tick off completion description: '{{qm.completion_description}}' </a> <br />
|
|||||||
Tick off url: <a href="/{{qm.get_completion_url}}">{{qm.get_completion_url}}</a> WRONG <br />
|
Tick off url: <a href="/{{qm.get_completion_url}}">{{qm.get_completion_url}}</a> WRONG <br />
|
||||||
Tick off date: '{{qm.completion_date}}' [For survex file ticks. not implemented yet]</a> <br />
|
Tick off date: '{{qm.completion_date}}' [For survex file ticks. not implemented yet]</a> <br />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
QM page_ref: '{{qm.page_ref}}'<br>
|
||||||
|
|
||||||
{% if qm.cave %}
|
{% if qm.cave %}
|
||||||
<h3>Cave: {{qm.cave|safe }}</h3>
|
<h3>Cave: {{qm.cave|safe }}</h3>
|
||||||
<a href="{% url 'caveQMs' qm.cave|safe %}">All QMs on this cave </a>{{ qm.cave|safe }} <br>
|
{{ qm.cave|safe }}<a href="{% url 'caveQMs' qm.cave|safe %}">All QMs </a> <br>
|
||||||
<a href="/{{ qm.cave.url }}"> Cave description </a> {{ qm.cave|safe }}
|
{{ qm.cave|safe }}<a href="/{{ qm.cave.url }}"> description </a> <br />
|
||||||
|
{{ qm.cave }} <a href="/survexfile/{{ qm.cave.kataster_number }}"> survexfiles </a> <br />
|
||||||
{% else %}
|
{% else %}
|
||||||
<h3>This QM is OPEN</h3>
|
<h3>This QM is OPEN</h3>
|
||||||
Comment: '{{qm.comment}}'</a> <br />
|
Comment: '{{qm.comment}}'</a> <br />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
QM page_ref: '{{qm.page_ref}}'<br>
|
|
||||||
|
|
||||||
<h3>QM Number: {{qm.number}} Grade: {{qm.grade}} </h3>
|
<h3>QM Number: {{qm.number}} Grade: {{qm.grade}} </h3>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user