From 820936ae982cb64c4c84f1c59f3c52ae4e207496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdulkadir=20Furkan=20=C5=9Eanl=C4=B1?= Date: Fri, 11 Jan 2019 11:54:57 +0100 Subject: [PATCH] Fix select_final_time(). --- ib-clearance.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/ib-clearance.py b/ib-clearance.py index a8273aa..f8d7489 100755 --- a/ib-clearance.py +++ b/ib-clearance.py @@ -79,7 +79,7 @@ def select_final_time(conn, day, stuple): LIMIT 1 """, (stuple[0], day, stuple[1])) ib_finish = cur.fetchone() - if ib_finish != None: + if ib_finish is not None: ib_finish = parse_time_string(ib_finish[0]) others = [] @@ -94,19 +94,23 @@ def select_final_time(conn, day, stuple): ORDER BY end_time DESC LIMIT 1 """, (sub, stuple[0], day, stuple[1])) - other_final = cur.fetchone() - if other_final != None: - others.append(parse_time_string(other_final[0])) + other_finish = cur.fetchone() + if other_finish is not None: + others.append(parse_time_string(other_finish[0])) if not others: - other_finish = None + others_finish = None else: - other_finish = max(others) + others_finish = max(others) - if ib_finish != None and other_finish != None: - if ib_finish > other_finish: + if ib_finish is not None and others_finish is not None: + if ib_finish > others_finish: finish = ib_finish else: - finish = other_finish + finish = others_finish + elif ib_finish is not None: + finish = ib_finish + elif others_finish is not None: + finish = others_finish else: finish = None @@ -139,7 +143,7 @@ def main(): elif finish_time < current_time: print("Student has finished for today, clear to leave.") else: - print("Student still has lessons, clearance not granted.") + print("\nStudent still has lessons, clearance not granted.") if input("Enter y to run again.") not in ["y", "Y"]: break