mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-03-30 07:49:51 +01:00
stop print msgs in utils and models
This commit is contained in:
@@ -67,13 +67,14 @@ def make_valid_date(walletname, date):
|
||||
samedate = datetime.date(y, m, d)
|
||||
try:
|
||||
swapdate = datetime.date(y, d, m)
|
||||
print(f"! - ERROR, not in ISO format. datestr='{datestr}'day and month are ambiguous {samedate.isoformat()} {walletname}")
|
||||
# print(f"! - ERROR, not in ISO format. datestr='{datestr}'day and month are ambiguous {samedate.isoformat()} {walletname}")
|
||||
except ValueError:
|
||||
# swapping day and month does not produce a valid date
|
||||
print(f"- - Warning, not in ISO format. datestr='{datestr}' but we tried to guess: {samedate.isoformat()} {walletname}")
|
||||
pass
|
||||
# print(f"- - Warning, not in ISO format. datestr='{datestr}' but we tried to guess: {samedate.isoformat()} {walletname}")
|
||||
return samedate
|
||||
except ValueError:
|
||||
print(f"! - Fail, tried to decompose date in dd-mm-yyyy format but failed: datestr='{datestr}'")
|
||||
# print(f"! - Fail, tried to decompose date in dd-mm-yyyy format but failed: datestr='{datestr}'")
|
||||
return None # Stop processing
|
||||
|
||||
# --- 3. Attempt ISO-Like Format (yyyy-m-d or yyyy-mm-dd) ---
|
||||
@@ -90,15 +91,16 @@ def make_valid_date(walletname, date):
|
||||
|
||||
try:
|
||||
samedate = datetime.date(y, m, d)
|
||||
print(f"- - Warning, 1 digit only for month or day datestr='{datestr}' but we coped: {samedate.isoformat()} {walletname}")
|
||||
# print(f"- - Warning, 1 digit only for month or day datestr='{datestr}' but we coped: {samedate.isoformat()} {walletname}")
|
||||
return samedate
|
||||
except ValueError:
|
||||
print(f"! - Fail, tried to decompose date in yyyy-m-d format but failed: datestr='{datestr}'")
|
||||
# print(f"! - Fail, tried to decompose date in yyyy-m-d format but failed: datestr='{datestr}'")
|
||||
return None # Stop processing
|
||||
|
||||
# --- 4. Final Failure Check ---
|
||||
if datestr and datestr != "None":
|
||||
print(f"! - Failed to understand date, none of our tricks worked datestr='{datestr}'")
|
||||
pass
|
||||
# print(f"! - Failed to understand date, none of our tricks worked datestr='{datestr}'")
|
||||
|
||||
return None
|
||||
|
||||
@@ -229,7 +231,7 @@ class Wallet(models.Model):
|
||||
y = int(wyear)
|
||||
except:
|
||||
message = f"! Exception: Error or 3 or more deep subfolder detected?:\n {fp.parent.name=}\n {fp.name=} \n {self.fpath=} {wurl=}"
|
||||
print(message)
|
||||
# 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
|
||||
@@ -243,11 +245,11 @@ class Wallet(models.Model):
|
||||
jsonfile = Path(settings.DRAWINGS_DATA, "walletjson") / wyear / wname / "contents.json"
|
||||
if not Path(jsonfile).is_file():
|
||||
message = f"! {jsonfile} is not a file:\n {wyear=} (should be eg. '2035')\n {wname=} (should be eg. '2035#13')\n {self.fpath=}"
|
||||
print(message)
|
||||
# print(message)
|
||||
|
||||
if wname not in archaic_wallets:
|
||||
message = f"! {jsonfile} (not archaic) is not a file:\n {wyear=} (should be eg. '2023')\n {wname=} (should be eg. '2023#13')\n {self.fpath=}"
|
||||
print(message)
|
||||
# print(message)
|
||||
from troggle.core.models.troggle import DataIssue
|
||||
DataIssue.objects.update_or_create(parser="wallets", message=message, url=wurl)
|
||||
return None
|
||||
@@ -257,7 +259,7 @@ class Wallet(models.Model):
|
||||
waldata = json.load(json_f)
|
||||
except:
|
||||
message = f"! {str(self.walletname)} Failed to load {jsonfile} JSON file"
|
||||
print(message)
|
||||
# print(message)
|
||||
from troggle.core.models.troggle import DataIssue
|
||||
DataIssue.objects.update_or_create(parser="wallets", message=message, url=wurl)
|
||||
return None
|
||||
@@ -314,7 +316,7 @@ class Wallet(models.Model):
|
||||
message = f"FAIL adding cave {caveobject} to wallet.caves '{i}'"
|
||||
|
||||
DataIssue.objects.update_or_create(parser="wallets", message=message, url=wurl)
|
||||
print(message)
|
||||
# print(message)
|
||||
pass
|
||||
|
||||
def year(self):
|
||||
@@ -502,16 +504,16 @@ class Wallet(models.Model):
|
||||
zipfiles = True
|
||||
|
||||
if zipfiles:
|
||||
print(f".zip file or .top file found at {self.walletname}")
|
||||
# print(f".zip file or .top file found at {self.walletname}")
|
||||
waldata["electronic survey"] = True
|
||||
|
||||
if topodroid:
|
||||
waldata["electronic survey"] = True
|
||||
print(f"topodroid found at {self.walletname}")
|
||||
# print(f"topodroid found at {self.walletname}")
|
||||
|
||||
if sexytopo:
|
||||
waldata["electronic survey"] = True
|
||||
print(f"sexytopo found at {self.walletname}")
|
||||
# print(f"sexytopo found at {self.walletname}")
|
||||
for f in files:
|
||||
# This list 'files' is only used to calculate tick lists and to colour the boxes
|
||||
if str(f).endswith("ext-elevation.json"):
|
||||
|
||||
Reference in New Issue
Block a user