Tidying logging and comments

This commit is contained in:
Fred Boniface 2023-06-05 21:04:20 +01:00
parent 2ca5a86030
commit dfe5e5830b

View File

@ -27,13 +27,16 @@ def requiresUpdate():
with open(file_location, "r") as f: with open(file_location, "r") as f:
text = f.read() text = f.read()
newHash = hashlib.md5(text.encode()).hexdigest() newHash = hashlib.md5(text.encode()).hexdigest()
log.out(f"pis.requiresUpdate: Existing PIS Hash: {currentHash}","INFO")
log.out(f"pis.requiresUpdate: New PIS hash: {newHash}", "INFO")
if currentHash is None or newHash != currentHash: if currentHash is None or newHash != currentHash:
log.out(f"pis.requiresUpdate: currentHash: {currentHash}, newHash: {newHash}", "INFO") log.out("pis.requiredUpdate: PIS Data requires updating", "INFO")
mongo.putMetaHash("pis", newHash) mongo.putMetaHash("pis", newHash)
return True return True
log.out("pis.requiredUpdate: PIS Data is up to date", "INFO")
return False return False
def load(): # Programatically add a `toc` field to each entry. def load():
with open(file_location, "r") as data: with open(file_location, "r") as data:
try: try:
pis = yaml.safe_load(data) pis = yaml.safe_load(data)
@ -64,13 +67,11 @@ def parse(codeList):
def getTiploc(crs :str): def getTiploc(crs :str):
CRS = crs.upper() CRS = crs.upper()
#log.out(f"pis.getTiploc: Finding TIPLOC for {CRS}")
query = { query = {
'3ALPHA': CRS '3ALPHA': CRS
} }
try: try:
res = mongo.query("stations", query) res = mongo.query("stations", query)
#print(res)
if 'TIPLOC' in res: if 'TIPLOC' in res:
return res['TIPLOC'] return res['TIPLOC']
except Exception as e: except Exception as e: