summaryrefslogtreecommitdiffstats
path: root/parsers/survex.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2022-07-15 14:09:32 +0300
committerPhilip Sargent <philip.sargent@klebos.com>2022-07-15 14:09:32 +0300
commit86a18c3ebccf737142abedfc3b3ba40296c6aecd (patch)
tree0399e4fdbf12251fc333effbbf0cfa9223ae4758 /parsers/survex.py
parent5582d545a163c58216b32434b658a7712a893365 (diff)
downloadtroggle-86a18c3ebccf737142abedfc3b3ba40296c6aecd.tar.gz
troggle-86a18c3ebccf737142abedfc3b3ba40296c6aecd.tar.bz2
troggle-86a18c3ebccf737142abedfc3b3ba40296c6aecd.zip
catch nonUTF8 survex files, DataIssues url editor
Diffstat (limited to 'parsers/survex.py')
-rw-r--r--parsers/survex.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/parsers/survex.py b/parsers/survex.py
index 70ff0d3..8baa9bf 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -1140,7 +1140,18 @@ class LoadingSurvex():
return
self.svxfileslist.append(path)
- svxlines = fin.read().splitlines()
+ try:
+ svxlines = fin.read().splitlines()
+ except UnicodeDecodeError:
+ # some bugger put an umlaut in a non-UTF survex file ?!
+ message = f" ! ERROR *include file '{path}' in '{survexblock}' has UnicodeDecodeError"
+ print(message)
+ print(message,file=sys.stderr)
+ offendingfile = "/survexfile/" + path + ".svx"
+ DataIssue.objects.create(parser='survex', message=message, url=offendingfile)
+ return # skip this survex file and all things *included in it
+
+
for svxline in svxlines:
self.lineno += 1
thissvxline += 1
@@ -1153,7 +1164,7 @@ class LoadingSurvex():
print(message)
print(message,file=sys.stderr)
DataIssue.objects.create(parser='survex', message=message)
- return # skip this survex file
+ return # skip this survex file and all things *included in it
includestmt =self.rx_include.match(svxline)
if not includestmt: