better integration of svx file DatIssues

This commit is contained in:
Philip Sargent
2021-04-14 21:08:06 +01:00
parent db3addc819
commit d598a6d0f5
4 changed files with 28 additions and 12 deletions

View File

@@ -104,10 +104,13 @@ class SvxForm(forms.Form):
outputtype = forms.CharField(widget=forms.TextInput(attrs={"readonly":True}))
code = forms.CharField(widget=forms.Textarea(attrs={"cols":150, "rows":36}))
template = False
def GetDiscCode(self):
fname = survexdatasetpath / (self.data['filename'] + ".svx")
if not os.path.isfile(fname):
print(">>> >>> WARNING - svx file not found, showing TEMPLATE SVX",fname, flush=True)
self.template = True
return survextemplatefile
fin = open(fname, "rt",encoding='utf8',newline='')
svxtext = fin.read()
@@ -167,6 +170,8 @@ def svx(request, survex_file):
editing) with buttons which allow SAVE, check for DIFFerences from saved, and RUN (which runs the
cavern executable and displays the output below the main textarea). Requires CSRF to be set upcorrect;ly, and requires permission to write to the filesystem.
'''
warning = False
# get the basic data from the file given in the URL
dirname = os.path.split(survex_file)[0]
dirname += "/"
@@ -210,7 +215,8 @@ def svx(request, survex_file):
#process(survex_file)
if 'code' not in form.data:
form.data['code'] = form.GetDiscCode()
if form.template:
warning = True
if not difflist:
difflist.append("none")
if message:
@@ -220,6 +226,7 @@ def svx(request, survex_file):
svxincludes = re.findall(r'\*include\s+(\S+)(?i)', form.data['code'] or "")
vmap = {'settings': settings,
'warning': warning,
'has_3d': os.path.isfile(survexdatasetpath / survex_file / ".3d"),
'title': survex_file,
'svxincludes': svxincludes,