2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

recognise old cave id codes in old wallets "1623-"

This commit is contained in:
Philip Sargent 2023-09-16 13:53:05 +03:00
parent a8d4b05617
commit 9db0b2a191

View File

@ -86,17 +86,26 @@ def fillblankpeople(w):
# print(f' - {wp=} {nobody=}') # print(f' - {wp=} {nobody=}')
populatewallet(w) populatewallet(w)
def is_cave(id): def is_cave(wallet, id):
if not id:
return False
Gcavelookup = GetCaveLookup() Gcavelookup = GetCaveLookup()
id = id.strip("' []'") id = id.strip("' []'")
if id in Gcavelookup: if id in Gcavelookup:
return True return True
else: else:
print(f" - Failed to find cave object from id <{id}>") # Historic wallets used just 2 or 3 digits and were all 1623 area. So, just for these wallets,
if id.lower() != "unknown" and id != "": # assume it is 1623-xxx
print(f" - adding <{id}> to pendingcaves.txt list") if f"1623-{id}" in Gcavelookup:
add_cave_to_pending_list(id, f"Could not find id <{id}>") print(f" - Should modify wallet {wallet} to us 1623- prefix for cave <{id}>")
return False Gcavelookup[id] = Gcavelookup[f"1623-{id}"] # restoring ambiguous alias
return True
else:
print(f" - Wallet {wallet} Failed to find cave object from id <{id}>")
if id.lower() != "unknown" and id != "":
print(f" - adding <{id}> to pendingcaves.txt list")
add_cave_to_pending_list(id, f"Wallet {wallet} - Could not find id <{id}>")
return False
def fillblankothers(w): def fillblankothers(w):
"""This is on the way to having a many:many relationship between Caves and Wallets """This is on the way to having a many:many relationship between Caves and Wallets
@ -113,17 +122,17 @@ def fillblankothers(w):
if type(wcaveid) == list: if type(wcaveid) == list:
for i in wcaveid: for i in wcaveid:
i = i.strip("' []'") i = i.strip("' []'")
if is_cave(i): if is_cave(w,i):
w.caveobj = Gcavelookup[i] # just sets it to the last one found. nasty. bug waiting to happen w.caveobj = Gcavelookup[i] # just sets it to the last one found. nasty. bug waiting to happen
elif wcaveid.find(',') != -1: elif wcaveid.find(',') != -1:
# it's a list of cave ids as a string # it's a list of cave ids as a string
ids = wcaveid.split(',') ids = wcaveid.split(',')
for i in ids: for i in ids:
i = i.strip("' []'") i = i.strip("' []'")
if is_cave(i): if is_cave(w,i):
w.caveobj = Gcavelookup[i] # just sets it to the last one found. nasty. bug waiting to happen w.caveobj = Gcavelookup[i] # just sets it to the last one found. nasty. bug waiting to happen
else: else:
if is_cave(wcaveid): if is_cave(w,wcaveid):
w.caveobj = Gcavelookup[wcaveid.strip("' []'")] w.caveobj = Gcavelookup[wcaveid.strip("' []'")]
@ -267,7 +276,7 @@ def cavewallets(request, caveid):
ids = cleanid.split(',') ids = cleanid.split(',')
for i in ids: for i in ids:
i = i.strip("' []'") i = i.strip("' []'")
if is_cave(i): if is_cave(z,i):
fcave = Gcavelookup[i.strip("' []'")] # just sets it to the last one found. nasty. bug waiting to happen fcave = Gcavelookup[i.strip("' []'")] # just sets it to the last one found. nasty. bug waiting to happen
elif cleanid in Gcavelookup: elif cleanid in Gcavelookup: