mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 07:11:52 +00:00
making the #00 wallet a catch-all and no complaining
This commit is contained in:
parent
99b87f808c
commit
6630877b02
@ -980,8 +980,23 @@ class LoadingSurvex:
|
||||
|
||||
def LoadSurvexRef(self, survexblock, args):
|
||||
"""Interpret the *ref record, and all the many variants
|
||||
|
||||
todo: check the year, ie that the *ref 2017#56 wallet is for a survexblock dated in 2017.
|
||||
"""
|
||||
# print(self.insp+ "*REF ---- '"+ args +"'")
|
||||
def check_reused_wallet():
|
||||
if walletnum == "00":
|
||||
# we don't mind if lost of survex files refer to the index wallet.
|
||||
# this is a way of saying that there is no wallet - someone has investigated.
|
||||
pass
|
||||
message = f" ! Wallet *REF {refscan} in {survexblock.survexfile.path} - re-uses #00 '{survexblock.scanswallet.walletname}'"
|
||||
print(self.insp + message)
|
||||
print(self.insp + message, file=sys.stderr)
|
||||
else:
|
||||
message = f" ! Wallet *REF {refscan} in {survexblock.survexfile.path} - Already a DIFFERENT wallet is set for this block '{survexblock.scanswallet.walletname}'"
|
||||
print(self.insp + message)
|
||||
stash_data_issue(parser="ref", message=message, url=url)
|
||||
return
|
||||
|
||||
url = get_offending_filename(survexblock.survexfile.path)
|
||||
# *REF but also ; Ref years from 1960 to 2039
|
||||
refline = self.rx_ref_text.match(args)
|
||||
@ -998,7 +1013,7 @@ class LoadingSurvex:
|
||||
|
||||
argsgps = self.rx_argsref.match(args)
|
||||
if argsgps:
|
||||
yr, letterx, wallet = argsgps.groups()
|
||||
yr, letterx, walletnum = argsgps.groups()
|
||||
else:
|
||||
perps = get_people_on_trip(survexblock)
|
||||
message = f" ! Wallet *REF bad in '{survexblock.survexfile.path}' malformed id '{args}' {perps}"
|
||||
@ -1006,23 +1021,20 @@ class LoadingSurvex:
|
||||
stash_data_issue(parser="ref", message=message, url=url)
|
||||
return
|
||||
|
||||
if not letterx:
|
||||
letterx = ""
|
||||
else:
|
||||
letterx = "X"
|
||||
if letterx:
|
||||
message = f" ! Wallet *REF has LETTER in '{survexblock.survexfile.path}' malformed id '{args}' {perps}"
|
||||
print(self.insp + message)
|
||||
stash_data_issue(parser="ref", message=message, url=url)
|
||||
if len(wallet) < 2:
|
||||
wallet = "0" + wallet
|
||||
if len(walletnum) < 2:
|
||||
walletnum = "0" + walletnum
|
||||
if not (int(yr) > 1960 and int(yr) < 2050):
|
||||
message = " ! Wallet year out of bounds {yr} '{refscan}' {survexblock.survexfile.path}"
|
||||
print(self.insp + message)
|
||||
stash_data_issue(parser="ref", message=message, url=url)
|
||||
|
||||
refscan = f"{yr}#{letterx}{wallet}"
|
||||
refscan = f"{yr}#{walletnum}"
|
||||
try:
|
||||
if int(wallet) > 99:
|
||||
if int(walletnum) > 99:
|
||||
message = f" ! Wallet *REF {refscan} - very big (more than 99) so probably wrong in '{survexblock.survexfile.path}'"
|
||||
print(self.insp + message)
|
||||
stash_data_issue(parser="ref", message=message, url=url)
|
||||
@ -1031,6 +1043,7 @@ class LoadingSurvex:
|
||||
print(self.insp + message)
|
||||
stash_data_issue(parser="ref", message=message, url=url)
|
||||
|
||||
# Look to see if we have a record of this wallet already - which would be unexpected
|
||||
manywallets = Wallet.objects.filter(
|
||||
walletname=refscan
|
||||
) # assumes all wallets found in earlier pass of data import
|
||||
@ -1041,10 +1054,12 @@ class LoadingSurvex:
|
||||
stash_data_issue(parser="ref", message=message, url=url)
|
||||
|
||||
if survexblock.scanswallet:
|
||||
if survexblock.scanswallet.walletname != refscan:
|
||||
message = f" ! Wallet *REF {refscan} in {survexblock.survexfile.path} - Already a DIFFERENT wallet is set for this block '{survexblock.scanswallet.walletname}'"
|
||||
print(self.insp + message)
|
||||
stash_data_issue(parser="ref", message=message, url=url)
|
||||
if survexblock.scanswallet.walletname == refscan:
|
||||
# this might happen when a survex file is re-parsed after editing, but if it is the same thing then OK.
|
||||
pass
|
||||
else:
|
||||
check_reused_wallet()
|
||||
|
||||
else:
|
||||
survexblock.scanswallet = manywallets[0] # this is a ForeignKey field
|
||||
survexblock.save()
|
||||
|
Loading…
Reference in New Issue
Block a user