2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-17 13:47:16 +00:00

begun to do fields, blue

This commit is contained in:
2025-01-31 01:51:22 +00:00
parent e080610010
commit 4a0496b3b4
3 changed files with 73 additions and 30 deletions

View File

@@ -1,3 +1,4 @@
import re
from pathlib import Path
import django.forms as forms
@@ -23,21 +24,20 @@ is 'katastered', ie.e moves from an informal number, such as
"""
def kataster(request, slug):
if cave := get_cave_from_slug(slug.lower()):
pass
elif cave := get_cave_from_slug(slug.upper()):
pass
else:
return HttpResponseRedirect("/caves")
"""Create the page which analyses how to rename a cave and all the files from the unofficial_number
identifier, e.g. 1623-2023-mg-03 to the kataster number e.g. 1623-999
"""
def do_file_finding():
knum = 9999
filename = str(cave) + ".html"
global cavefilename, cave_data, entrance_data, loser_name, loser_data
cave_data = Path( "cave_data", filename )
if not (settings.EXPOWEB / cave_data).is_file:
cavefilename = str(cave) + ".html"
cave_data = Path( "cave_data", cavefilename )
if not (settings.CAVEDESCRIPTIONS / cavefilename).is_file: # settings.EXPOWEB / cave_data
cave_data = "does not exist"
ent_dir = settings.EXPOWEB / "entrance_data"
ent_dir = settings.ENTRANCEDESCRIPTIONS # settings.EXPOWEB / "entrance_data"
entrance_data = []
for ent in ent_dir.iterdir():
@@ -54,6 +54,35 @@ def kataster(request, slug):
print(svx)
loser_data.append(Path(loser_dir , svx).name)
if cave := get_cave_from_slug(slug.lower()):
pass
elif cave := get_cave_from_slug(slug.upper()):
pass
else:
return HttpResponseRedirect("/caves")
knum = 9999
do_file_finding()
try:
# this is a python generator idiom.
# see https://realpython.com/introduction-to-python-generators/
with open(settings.CAVEDESCRIPTIONS / cavefilename, 'r') as f:
for line in f:
if match := re.search(r'<entranceslug>(.*?)</entranceslug>', line):
entrance = match.group(1)
print(entrance)
except PermissionError as e:
msg=f"CANNOT save this file.\nPERMISSIONS incorrectly set on server for this file {filepath}. Ask a nerd to fix this: {e}"
print(msg)
raise
except Exception as e:
msg=f"CANNOT write this file {filepath}. Ask a nerd to fix this: {e}"
print(msg)
if request.method == "POST": # If the form has been submitted...
form = KatasterForm(request.POST) # A form bound to the POST data
if form.is_valid():

View File

@@ -379,6 +379,9 @@ def getXML(text, itemname, minItems=1, maxItems=None, context=""):
This always succeeds, but it produces error message on the terminal and in the
DataIssues log.
Yes this is using the python2 style of string expansion and not f-expressions.
Sorry. This is very old.
"""
items = re.findall("<%(itemname)s>(.*?)</%(itemname)s>" % {"itemname": itemname}, text, re.S)
if len(items) < minItems:

View File

@@ -29,7 +29,12 @@ This cave needs to be "katastered". If you have the new number issued by the Aus
<h3>Rename the .html files in <var>expoweb</var></h3>
<div style="font-family: monospace; font-weight: bold;">
{{cave_data|safe}}
{{cave_data|safe}}<br />
&nbsp;&nbsp;&nbsp;<span style="color:grey">&lt;kataster_number&gt;</span><span style="color:grey">&lt;/kataster_number&gt;</span>
<br />
&nbsp;&nbsp;&nbsp;
&rarr;
<span style="color:grey">&lt;kataster_number&gt;</span><span style="color:blue">{{knum}}</span><span style="color:grey">&lt;/kataster_number&gt;</span>
<p>
{% for e in entrance_data %}
{{e|safe}}</br />
@@ -46,7 +51,7 @@ This cave needs to be "katastered". If you have the new number issued by the Aus
<h3>Rename the cave description directory in <var>expoweb</var></h3>
<ul style="list-style: disc">
<li> Edit all the '<samp>href=</samp>' <small>URLS</small> (if they exist) inside all the <samp>cave_data</samp> and <samp>entrance_data</samp> files descriptive text to refer to the new directory
<li> Rename the directory (if it exists) inside the areacode directory, e.g. rename <samp>/{{cave.areacode}}/{{cave.unofficial_number}}/</samp> as <samp>/{{cave.areacode}}/{{knum}}/</samp> (if {{knum}} is the correct new kataster number). Do this last.
<li> Rename the directory (if it exists) inside the areacode directory, e.g. rename <samp>/{{cave.areacode}}/{{cave.unofficial_number}}/</samp> as <samp>/{{cave.areacode}}/<span style="color:blue">{{knum}}</span>/</samp> (if <span style="color:blue">{{knum}}</span> is the correct new kataster number). Do this last.
</ul>
@@ -60,40 +65,46 @@ This cave needs to be "katastered". If you have the new number issued by the Aus
</div>
<ul style="list-style: disc">
<li> Find the survex files for this cave and edit the <samp>*include</samp> inside the survex files to use the new kataster number
<li> find and edit the '*_station' tags in each entrance_data file and in the fixed points files in the loser repo.
<li> find and edit the <samp>'*_station'</samp> tags in each <samp>entrance_data</samp> file and in the fixed points files in the loser repo.
<li> Rename the survex files
<li> Run <samp>'cavern caves-{{cave.areacode |safe}}/{{knum}}/{{knum}}.svx'</samp> and check it all works as you hope
<li> Run <samp>'cavern caves-{{cave.areacode |safe}}/<span style="color:blue">{{knum}}/{{knum}}.svx</span>'</samp> and check it all works as you hope
<li> Run <samp>'cavern caves-{{cave.areacode |safe}}/caves.svx' </samp> and check it all works as you hope
</ul>
<h3>Sort out the *fix point(s) in both <var>loser</var> and in <var>expoweb</var></h3>
<ul style="list-style: disc">
<li> Find the *fix point for each entrance (one or more in each <samp>entrance_data</samp> file) in <var>expoweb</var>
<li> Find the *fix point for each entrance (one or more in each <samp>entrance_data</samp> file) in <var>expoweb</var>. There are three fields where there might be a *fix value: <samp>'tag_station', 'exact_station'</samp> and <samp>'other_station'</samp>
<li> Change the name of each *fix point in the relevant survex file in <var>loser</var>
<li> Make the same name change(s) in each entrance file (in each <samp>entrance_data</samp> file) in <var>expoweb</var>
</ul>
<p>Without fully parsing the entire survex *include tree (which this code does not do), it is impossible to find the *fix declaration file from the <samp>'station'</samp> fields in the entrance_data files. However in area 1623 we conventionally store the *fix in a "known" place. This does not work for area 1626.
<h3>Set the historic alias forwarder in <var>expoweb</var></h3>
<ul style="list-style: disc">
<li> Add the line <br /><samp>("{{cave.slug|safe}}", "{{cave.areacode |safe}}-{{knum}}"),</samp></br /> to the end
<li> Add the line <br /><samp>("{{cave.slug|safe}}", "<span style="color:blue">{{cave.areacode |safe}}-{{knum}}</span>"),</samp></br /> to the end
of the file <var><a href="/cave_data/cavealiases.txt_edit">cave_data/cavealiases.txt</a></var> (don't forget the comma at the end of the line)
</ul>
<p>This will cause lost of errors until the cave <samp>"<span style="color:blue">{{cave.areacode |safe}}-{{knum}}</span>"</samp> has been created by a full database reset.
<!--or by editing & saving the cave description page <a href="/{{cave.areacode |safe}}/{{knum}}">/{{cave.areacode |safe}}/{{knum}}</a> after renaming. (Editing a cave description page regenerates some of the internal indices.)
-->
<h3>Finally</h3>
<ul style="list-style: disc">
<li><samp>cd loser<br />
git add *<br />
git commit -m 'Katastering {{cave.slug|safe}} to {{cave.areacode |safe}}-{{knum}}'<br />
git commit -m 'Katastering {{cave.slug|safe}} to <span style="color:blue">{{cave.areacode |safe}}-{{knum}}</span>'<br />
git pull<br />
git push<br />
cd ../expoweb<br />
git add *<br />
git commit -m 'Katastering {{cave.slug|safe}} to {{cave.areacode |safe}}-{{knum}}'<br />
git commit -m 'Katastering {{cave.slug|safe}} to <span style="color:blue">{{cave.areacode |safe}}-{{knum}}</span>'<br />
git pull<br />
git push<br />
</samp>
<li>It is then vital to do a complete databaseReset as troggle has internally indexed all those {{cave.slug}} files, the indexes are now out of date and horrible things will happen when people try to use troggle with any cave that has been altered:<br />
<samp>uv run databaseReset reset K{{knum}}</samp>
<samp>uv run databaseReset reset <span style="color:blue">K{{knum}}</span></samp>
<li>Look in the reset import warnings and errors report to see if anything has gone wrong:
<var><a href="http://expo.survex.com/dataissues">expo.survex.com/dataissues</a></var><br />
(in fact, look at this before you do any of this, so you can see what chnages.)