mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-16 23:37:03 +00:00
cleaned up wallets import process
This commit is contained in:
@@ -81,6 +81,9 @@ def load_all_scans():
|
||||
# they are if they are /2010/2010#33
|
||||
# or /1996-1999NotKHbook/
|
||||
# but not if they are /2010/2010#33/therion/ : the wallet is /2010#33/ not /therion/
|
||||
|
||||
# READ THE FUNCTION get_json(self) in models/wallets which ALSO does this SAME job
|
||||
# needs refactoring
|
||||
print(" ", end="")
|
||||
scans_path = Path(settings.SCANS_ROOT)
|
||||
seen = set()
|
||||
@@ -96,19 +99,25 @@ def load_all_scans():
|
||||
pass
|
||||
else:
|
||||
c += 1
|
||||
if c % 60 == 0:
|
||||
if c % 120 == 0:
|
||||
print(".", end="")
|
||||
if c % 3000 == 0:
|
||||
if c % 6000 == 0:
|
||||
print("\n ", end="")
|
||||
|
||||
if p.parent.parent.parent.parent == scans_path:
|
||||
# the wallet has subfolders, which we are uninterested in at this point.
|
||||
# print(f"too deep {p}", end='\n')
|
||||
# Finding the wallet from deeply hidden subdirectories
|
||||
if p.parent.parent.parent.parent.parent.parent == scans_path:
|
||||
fpath = p.parent.parent.parent.parent
|
||||
walletname = p.parent.parent.parent.parent.name
|
||||
elif p.parent.parent.parent.parent.parent == scans_path:
|
||||
fpath = p.parent.parent.parent
|
||||
walletname = p.parent.parent.parent.name
|
||||
elif p.parent.parent.parent.parent == scans_path:
|
||||
fpath = p.parent.parent
|
||||
walletname = p.parent.parent.name # wallet is one level higher
|
||||
walletname = p.parent.parent.name
|
||||
else:
|
||||
fpath = p.parent
|
||||
walletname = p.parent.name
|
||||
|
||||
|
||||
if walletname in wallets: # assumes all walletnames are unique
|
||||
wallet = wallets[walletname]
|
||||
@@ -129,17 +138,14 @@ def load_all_scans():
|
||||
if len(tag) > 4:
|
||||
if tag[4] != "#":
|
||||
relative_path = p.relative_to(scans_path, walk_up=False)
|
||||
seen.add(str(relative_path.parent))
|
||||
seen.add((str(relative_path.parent)+"/", walletname))
|
||||
wjson = 0
|
||||
print("\n ", end="")
|
||||
seenlist = list(seen)
|
||||
seenlist.sort()
|
||||
|
||||
print("\n")
|
||||
for tag in seenlist:
|
||||
wjson += 1
|
||||
if wjson % 10 == 0:
|
||||
print("\n ", end="")
|
||||
print(f" {tag} ", end="")
|
||||
print(f" {tag} ", end="\n")
|
||||
print(f"\n - found and loaded {c:,} acceptable scan files in {len(wallets):,} wallets")
|
||||
|
||||
# but we also need to check if JSON exists, even if there are no uploaded scan files.
|
||||
|
||||
Reference in New Issue
Block a user