summaryrefslogtreecommitdiffstats
path: root/core/models/wallets.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2024-08-11 15:19:59 +0300
committerPhilip Sargent <philip.sargent@gmail.com>2024-08-11 15:19:59 +0300
commit74ce8894d2c0fa154f58b2dc2afb6e3332120284 (patch)
treecf7f5316d321457348b8e6c490a90c035b3bac1b /core/models/wallets.py
parente64cb212c19cd7bca1771381dd43740044ca5a5b (diff)
downloadtroggle-74ce8894d2c0fa154f58b2dc2afb6e3332120284.tar.gz
troggle-74ce8894d2c0fa154f58b2dc2afb6e3332120284.tar.bz2
troggle-74ce8894d2c0fa154f58b2dc2afb6e3332120284.zip
wallets subfolders fiddling
Diffstat (limited to 'core/models/wallets.py')
-rw-r--r--core/models/wallets.py32
1 files changed, 25 insertions, 7 deletions
diff --git a/core/models/wallets.py b/core/models/wallets.py
index 7dacc7d..d94d048 100644
--- a/core/models/wallets.py
+++ b/core/models/wallets.py
@@ -147,19 +147,37 @@ class Wallet(models.Model):
if hasattr(self, "JSONdata"):
return self.JSONdata
+
+ scans_path = Path(settings.SCANS_ROOT)
# :drawings: walletjson/2022/2022#01/contents.json
# fpath = /mnt/d/EXPO/expofiles/surveyscans/1999/1999#02
# This does not work if there are subdirectories in the surveyscan folder
fp = Path(self.fpath)
- wname = fp.name
- wyear = fp.parent.name
+ if fp.name in archaic_wallets:
+ return None
- try:
- y = int(wyear)
- except:
- message = f"! Subfolder detected?:\n {wyear=} (should be eg. '2023')\n {wname=} \n {self.fpath=}"
- print(message)
+ if fp.parent.parent.parent.parent == scans_path:
+ print(f" ! ", end="")
+ if fp.parent.parent.parent.parent.parent == scans_path:
+ print(f" !! ", end="")
+
+ if fp.parent.parent.parent.parent == scans_path:
+ subfolder = fp.parent.name
+ wname = fp.parent.parent.name
+ wyear = fp.parent.parent.parent.name
+ print(f"\n - Subfolder {subfolder} one deep, detected in {wname}")
+ else:
+ wname = fp.name
+ wyear = fp.parent.name
+ try:
+ y = int(wyear)
+ except:
+ message = f"\n! 2 or more deep subfolder detected?:\n {fp.parent.name=}\n {fp.name=} \n {self.fpath=}"
+ print(message)
+ # this is a hack, work down from /surveyscans instead. To be fixed
+ wname = fp.parent.parent.parent.name
+ wyear = fp.parent.parent.parent.parent.name
wurl = self.get_url()
if len(wyear) != 4 or len(wname) !=6: