summaryrefslogtreecommitdiffstats
path: root/core/views/drawings.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2022-10-15 17:25:41 +0300
committerPhilip Sargent <philip.sargent@klebos.com>2022-10-15 17:25:41 +0300
commit3b106a380356f1bb0c03d899c8a41d90d148ca9e (patch)
tree6bff3457ac875b834dc3f4a9cad995a975c6e1b4 /core/views/drawings.py
parentda09bc7968f0c57029f6044484d511244eb00812 (diff)
downloadtroggle-3b106a380356f1bb0c03d899c8a41d90d148ca9e.tar.gz
troggle-3b106a380356f1bb0c03d899c8a41d90d148ca9e.tar.bz2
troggle-3b106a380356f1bb0c03d899c8a41d90d148ca9e.zip
fix PCTEXT better in dis-laying tunnel files
Diffstat (limited to 'core/views/drawings.py')
-rw-r--r--core/views/drawings.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/core/views/drawings.py b/core/views/drawings.py
index e922433..073f017 100644
--- a/core/views/drawings.py
+++ b/core/views/drawings.py
@@ -22,6 +22,22 @@ todo='''- Need to check if invalid query string is invalid, or produces multiple
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;" : " ",
+ "&quot;" : "\"",
+ "&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):
'''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}')
lines = f.readlines()
#print(f'- finished reading {encoding}')
- #print(f'- {len(lines)=}')
clean = []
for l in lines:
- clean.append(l.replace('&amp;','@').replace('&','&amp;').replace('@', '&amp;'))
+ clean.append(unescape(l)) # deals with strangely embedded survex file
#print(f'- Cleaned and stripped.')
try:
return HttpResponse(content=clean, content_type="text/xml")