replace assert() with message logging

This commit is contained in:
Philip Sargent
2021-04-13 22:27:01 +01:00
parent 2467065ac3
commit daf58e9e45
8 changed files with 43 additions and 29 deletions

View File

@@ -213,7 +213,11 @@ class LoadingSurvex():
expo = self.expos[year]
else:
expeditions = Expedition.objects.filter(year=year)
assert len(expeditions) == 1
if len(expeditions) != 1 :
message = f"! More than one expedition in year {year} '{line}' ({survexblock}) {survexblock.survexfile.path}"
print((self.insp+message))
DataIssue.objects.create(parser='survexunits', message=message)
expo= expeditions[0]
self.expos[year]= expo
@@ -411,7 +415,11 @@ class LoadingSurvex():
letterx = "X"
if len(wallet)<2:
wallet = "0" + wallet
assert (int(yr)>1960 and int(yr)<2039), "Wallet year out of bounds: %s" % yr
if not (int(yr)>1960 and int(yr)<2039):
message = " ! Wallet year out of bounds {yr} '{refscan}' {survexblock.survexfile.path}"
print((self.insp+message))
DataIssue.objects.create(parser='survex', message=message)
refscan = "%s#%s%s" % (yr, letterx, wallet)
try:
if int(wallet)>100: