diff options
author | Martin Green <martin.speleo@gmail.com> | 2022-07-15 13:43:50 +0100 |
---|---|---|
committer | Martin Green <martin.speleo@gmail.com> | 2022-07-15 13:43:50 +0100 |
commit | ef2790112565e2266aa8583b8c6cc44fec054700 (patch) | |
tree | b9fae323cdb47c57cc509ad5167380592f231a15 /parsers/survex.py | |
parent | a1560c60c686aadf4963b42d5a0c5b6dd80158d7 (diff) | |
parent | b8355cbf8d38e86e162604f4b3416d38f503d7a8 (diff) | |
download | troggle-ef2790112565e2266aa8583b8c6cc44fec054700.tar.gz troggle-ef2790112565e2266aa8583b8c6cc44fec054700.tar.bz2 troggle-ef2790112565e2266aa8583b8c6cc44fec054700.zip |
Merge branch 'python3-new' of ssh://expo.survex.com/home/expo/troggle into python3-new
Diffstat (limited to 'parsers/survex.py')
-rw-r--r-- | parsers/survex.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/parsers/survex.py b/parsers/survex.py index 70ff0d3..3deef71 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -835,7 +835,7 @@ class LoadingSurvex(): else: message = f' ! QM Unrecognised as a valid QM in "{survexblock.survexfile.path}" QM{qml.group(1)} {qml.group(2)}' print(message) - DataIssue.objects.create(parser='survex', message=message) + DataIssue.objects.create(parser='survex', message=message, url=f'/survexfile/{survexblock.survexfile.path}.svx') included = self.rx_comminc.match(comment) @@ -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: |