mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
catch nonUTF8 survex files, DataIssues url editor
This commit is contained in:
parent
5582d545a1
commit
86a18c3ebc
@ -119,9 +119,14 @@ class SvxForm(forms.Form):
|
|||||||
print(">>> >>> WARNING - svx file not found, showing TEMPLATE SVX",fname, flush=True)
|
print(">>> >>> WARNING - svx file not found, showing TEMPLATE SVX",fname, flush=True)
|
||||||
self.template = True
|
self.template = True
|
||||||
return survextemplatefile
|
return survextemplatefile
|
||||||
|
try:
|
||||||
fin = open(fname, "r",encoding='utf8',newline='')
|
fin = open(fname, "r",encoding='utf8',newline='')
|
||||||
svxtext = fin.read()
|
svxtext = fin.read()
|
||||||
fin.close()
|
fin.close()
|
||||||
|
except:
|
||||||
|
fin = open(fname, "r",encoding='iso-8859-1',newline='')
|
||||||
|
svxtext = fin.read()
|
||||||
|
fin.close()
|
||||||
return svxtext
|
return svxtext
|
||||||
|
|
||||||
def DiffCode(self, rcode):
|
def DiffCode(self, rcode):
|
||||||
|
@ -1140,7 +1140,18 @@ class LoadingSurvex():
|
|||||||
return
|
return
|
||||||
self.svxfileslist.append(path)
|
self.svxfileslist.append(path)
|
||||||
|
|
||||||
|
try:
|
||||||
svxlines = fin.read().splitlines()
|
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:
|
for svxline in svxlines:
|
||||||
self.lineno += 1
|
self.lineno += 1
|
||||||
thissvxline += 1
|
thissvxline += 1
|
||||||
@ -1153,7 +1164,7 @@ class LoadingSurvex():
|
|||||||
print(message)
|
print(message)
|
||||||
print(message,file=sys.stderr)
|
print(message,file=sys.stderr)
|
||||||
DataIssue.objects.create(parser='survex', message=message)
|
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)
|
includestmt =self.rx_include.match(svxline)
|
||||||
if not includestmt:
|
if not includestmt:
|
||||||
|
Loading…
Reference in New Issue
Block a user