2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

fix PCTEXT better in dis-laying tunnel files

This commit is contained in:
Philip Sargent 2022-10-15 17:25:41 +03:00
parent da09bc7968
commit 3b106a3803

View File

@ -22,6 +22,22 @@ todo='''- Need to check if invalid query string is invalid, or produces multiple
and render a user-friendly error page. and render a user-friendly error page.
''' '''
def unescape(input):
'''These look like HTML entities, but they are not. They are tunnel-specific encodings
'''
codes = {
"&space;" : " ",
""" : "\"",
"&tab;" : "\t",
"&backslash;" : "\\",
"&newline;" : "\n\t",
"&apostrophe": "'",
}
for c in codes:
#print(c, codes[c])
input = input.replace(c, codes[c])
return input
def dwgallfiles(request): def dwgallfiles(request):
'''Report on all the drawing files in the system. These were loaded by parsing the entire directory tree '''Report on all the drawing files in the system. These were loaded by parsing the entire directory tree
@ -54,10 +70,9 @@ def dwgfilesingle(request, path):
print(f'- before reading any {encoding}') print(f'- before reading any {encoding}')
lines = f.readlines() lines = f.readlines()
#print(f'- finished reading {encoding}') #print(f'- finished reading {encoding}')
#print(f'- {len(lines)=}')
clean = [] clean = []
for l in lines: for l in lines:
clean.append(l.replace('&','@').replace('&','&').replace('@', '&')) clean.append(unescape(l)) # deals with strangely embedded survex file
#print(f'- Cleaned and stripped.') #print(f'- Cleaned and stripped.')
try: try:
return HttpResponse(content=clean, content_type="text/xml") return HttpResponse(content=clean, content_type="text/xml")