mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-01-19 01:23:12 +00:00
removing template in-code step 1
This commit is contained in:
@@ -49,44 +49,52 @@ todo = """
|
||||
|
||||
SVXPATH = Path(settings.SURVEX_DATA)
|
||||
|
||||
# NB this template text must be identical to that in :loser:/templates/template.svx
|
||||
# NB this template text must be identical to that in
|
||||
templatepath = settings.SURVEX_DATA / "template" / "template.svx"
|
||||
survextemplatefile = """; *** THIS IS A TEMPLATE FILE - NOT WHAT YOU MIGHT BE EXPECTING ***
|
||||
|
||||
*** DO NOT SAVE THIS FILE WITHOUT RENAMING IT !! ***
|
||||
;[Stuff in square brackets is example text to be replaced, every square bracket
|
||||
; must be excised in order for the website to let you save the file]
|
||||
; Also REMOVE the reminders like "; <-- CHANGE THIS DATE" once you've done it.
|
||||
|
||||
; A semicolon at the beginning of a line means its a comment - you can write anything
|
||||
; you like after it without upsetting survex.
|
||||
; An asterisk means the line does something, proceed with caution
|
||||
|
||||
*begin [surveyname]
|
||||
*begin [surveyname] ; <-- always use a surveyname, do not leave this blank
|
||||
|
||||
; stations linked into other surveys (or likely to)
|
||||
*export [1 8 12 34]
|
||||
|
||||
; Cave name or number:
|
||||
; Area in cave surveyed/QM:
|
||||
*title "" ;[full descriptive name for survex file - delete/ignore if you are already happy with the '*begin' name]
|
||||
*date [2040.07.04] ; <-- CHANGE THIS DATE
|
||||
*title "" ;[Name of passage/section - delete/ignore if you are already happy with the '*begin' name]
|
||||
*date [2040.07.04] ; <-- CHANGE THIS DATE
|
||||
|
||||
*team ["Albert Aadvark"] Tape ; <-- CHANGE THE NAMES, in quotes if more than one word.
|
||||
*team ["Albert Aadvark"] Tape ; <-- CHANGE THE NAMES, in quotes if more than one word in a name
|
||||
; Insert as many or few people/roles as you like.
|
||||
; If someone is in this file the metres surveyed will be attributed to them.
|
||||
*team [Badger] Notes
|
||||
*team ["Fred Fossa"] insts
|
||||
*team [Grumpy] Pics
|
||||
[*instrument tape "CUCC Fisco Ranger open reel"] ; <-- CHANGE THIS to actual instrument
|
||||
; Calibration: [Have you? Where?]
|
||||
; *Calibration: ; <-- Have you? Where?
|
||||
|
||||
*ref [2040#00] ; <-- WALLET NAME, CHANGE THIS TOO
|
||||
*ref [2040#00] ; <-- WALLET NAME, CHANGE THIS TOO. Leave blank if unknown.
|
||||
; the #number is on the clear plastic wallet containing the original notes
|
||||
|
||||
; Centreline data - copy and paste from the exported Sexy Topo file, include the 'alias station' line
|
||||
; if there is a significant station maybe write a description? e.g. 'top of big boulder'.
|
||||
; Put a semicolon before any text.
|
||||
; Describe the first station, the tag (if present) and any GPS stations:
|
||||
;1 Convenient point that can see down cave, and the tag and GPS boulder. Nail Polish marked.
|
||||
;2 cave ID tag. Marked with tag and bolt.
|
||||
;4 GPS point on 1m boulder about 9m away SW from entrance tag. Nail polish marked.
|
||||
|
||||
; Centreline data
|
||||
; Copy and paste from the exported Sexy Topo file, include the 'alias station' line
|
||||
; Add station descriptions e.g. 'top of big boulder', 'LH wall, marked/numbered'.
|
||||
; Put a semicolon before non-data lines
|
||||
*data normal from to length bearing gradient ignoreall
|
||||
[ 1 2 5.57 034.5 -12.8 ] ; on top of boulder shaped like a rabbit
|
||||
[ 1 2 5.57 034.5 -12.8 on top of boulder shaped like a rabbit ]
|
||||
|
||||
; what colour nail polish?:
|
||||
|
||||
@@ -110,7 +118,7 @@ survextemplatefile = """; *** THIS IS A TEMPLATE FILE - NOT WHAT YOU MIGHT BE EX
|
||||
;[ QM2 B surveyname.5 surveyname.5 description of QM and description of why it crapped out ]
|
||||
|
||||
;------------
|
||||
;Cave description ;(leave commented-out)
|
||||
;Cave description ;(leave "commented-out", i.e. keep the initial semi-colon on each line)
|
||||
;Freeform text describing this section of the cave
|
||||
; more free form text
|
||||
; lots of description please. It will be copied and pasted into the Cave data page.
|
||||
@@ -125,12 +133,17 @@ survextemplatefile = """; *** THIS IS A TEMPLATE FILE - NOT WHAT YOU MIGHT BE EX
|
||||
; Splays arranged for each survey station (NB you only need to
|
||||
; explicitly flag splays if they are to named stations).
|
||||
;
|
||||
; Station splayID distance, heading, inclination
|
||||
; Station splayID (can be a dot for an anonymous station) distance, heading, inclination
|
||||
*begin
|
||||
*flags splay
|
||||
;[ 1 1a d h i]
|
||||
;[ 1 1b d h i]
|
||||
;[ 3 3a d h I]
|
||||
; e.g.
|
||||
;1 . 1.145 212.45 -4.39
|
||||
;1 . 7.432 229.66 -28.35
|
||||
;1 . 6.084 265.14 -32.88
|
||||
;1 . 17.365 228.51 -56.74
|
||||
*end
|
||||
|
||||
;------------------------------------------------------------------
|
||||
@@ -154,7 +167,15 @@ survextemplatefile = """; *** THIS IS A TEMPLATE FILE - NOT WHAT YOU MIGHT BE EX
|
||||
;[2 0.3 1.2 6 1.2 NP '2' LHW ]
|
||||
;[3 1.3 0 3.4 0.2 Rock on floor - not refindable ]
|
||||
|
||||
; if no LRUDs still make a note about stations:
|
||||
;Stations:
|
||||
;1 Convenient point that can see down cave, and the tag and GPS boulder. Nail Polish marked.
|
||||
;2 cave ID tag. Marked with tag and bolt.
|
||||
;3 Far wall somewhere down cave. Not marked.
|
||||
;4 GPS point on 1m boulder about 9m away SW from entrance tag. Nail polish marked.
|
||||
|
||||
|
||||
*end [surveyname]
|
||||
"""
|
||||
|
||||
def get_survexfile(filename):
|
||||
@@ -185,7 +206,9 @@ class SvxForm(forms.Form):
|
||||
see https://docs.djangoproject.com/en/5.1/topics/forms/modelforms/
|
||||
|
||||
This is unlike any other form in troggle. It has methods (functions) for a start.
|
||||
|
||||
It was apparently originally by Julian:
|
||||
[svn] codemirror
|
||||
goatchurch on 6/9/2009, 6:59:54 PM
|
||||
"""
|
||||
|
||||
dirname = forms.CharField(widget=forms.TextInput(attrs={"readonly": True}))
|
||||
@@ -210,6 +233,13 @@ class SvxForm(forms.Form):
|
||||
print(">>> >>> WARNING - svx file not found, showing TEMPLATE SVX", fname, flush=True)
|
||||
self.template = True
|
||||
self.survexfile = False
|
||||
with open(templatepath,"r") as tf:
|
||||
templatetext = tf.read()
|
||||
templ1 = templatetext.split()
|
||||
templ2 = survextemplatefile.split()
|
||||
for w in range(len(templ1)):
|
||||
if templ1[w] != templ2[w]:
|
||||
print(w, templ1[w], templ2[w])
|
||||
return survextemplatefile
|
||||
if not self.survexfile:
|
||||
if sf := get_survexfile(self.data["filename"]): # walrus!
|
||||
@@ -244,7 +274,7 @@ class SvxForm(forms.Form):
|
||||
if " " in self.data["filename"]:
|
||||
errmsg = "Error: Spaces are not possible in filenames.\n\nRename the file."
|
||||
return errmsg
|
||||
if re.search(r"\[|\]", rcode):
|
||||
if re.search(r"\[|\]|<--", rcode):
|
||||
errmsg = "Error: remove all []s from the text.\nEverything inside [] are only template guidance.\n\n"
|
||||
errmsg += "All [] must be edited out and replaced with real data before you can save this file.\n"
|
||||
return errmsg
|
||||
|
||||
Reference in New Issue
Block a user