Minor changes

This commit is contained in:
Abdulkadir Furkan Şanlı 2018-11-04 11:33:43 +01:00
parent 8d5fa18966
commit 70a4ca18ca

View File

@ -21,7 +21,7 @@ import time
def connect_database(file):
"""
Create and return Connection object
Creates and returns Connection object.
:param file: database file
"""
conn = sqlite3.connect(file)
@ -30,7 +30,7 @@ def connect_database(file):
def get_lower_weekday():
"""
Return current weekday's name as lowercase string
Returns current weekday's name as lowercase string.
"""
day = time.strftime("%A")
lower_day = day.lower()
@ -39,7 +39,7 @@ def get_lower_weekday():
def check_id(conn, id):
"""
Return True if existing ID, False is not.
Returns True if existing ID, False if not.
:param conn: Connection object
:param id: ID of student, int
"""
@ -56,7 +56,7 @@ def check_id(conn, id):
def select_final_time(conn, day, id):
"""
Return ending time of final lesson student must attend, or None.
Returns ending time of final lesson student must attend, or None.
:param conn: Connection object
:param day: current weekday, lowercase str
:param id: ID of student, int
@ -86,7 +86,7 @@ def select_final_time(conn, day, id):
def parse_time_string(timestring):
"""
Parse given 24h time string of format "HH:MM" into time_struct
Parses given 24h time string of format "HH:MM" into time_struct.
:param timestring: time string "HH:MM"
"""
timestruct = time.strptime(timestring, "%H:%M")
@ -95,7 +95,7 @@ def parse_time_string(timestring):
def main():
db = input(
"Please enter name of database (located in the same folder as the program): ")
"Please enter name of database (in same folder as program): ")
y = "y"
while y == "y":
@ -104,22 +104,24 @@ def main():
id = int(input("Please input the student ID number: "))
if check_id(conn, id):
raw = select_final_time(conn, day, id)
final = parse_time_string(raw) if raw != None else None
raw_time = select_final_time(conn, day, id)
final_time = parse_time_string(
raw_time) if raw_time != None else None
if final != None:
if final_time != None:
current_time = parse_time_string(time.strftime("%H:%M"))
if current_time > final:
if current_time > final_time:
print("Clear to leave.")
else:
print("Student does not have clearance.")
elif final == None:
elif final_time == None:
print("Clear to leave.")
else:
print("Student does not exist in the database. Please try again.")
y = input("Press y and enter to run again.")
y = input("Press y key followed by enter to run again.")
if __name__ == "__main__":