Functionalize exit sequence
This commit is contained in:
parent
19559802d8
commit
c095d1d330
@ -147,6 +147,20 @@ def parse_time_string(timestring):
|
|||||||
return structtime
|
return structtime
|
||||||
|
|
||||||
|
|
||||||
|
def exit_sequence():
|
||||||
|
"""Initiate exit sequence.
|
||||||
|
|
||||||
|
Asks user to enter character, and exits program if X is pressed.
|
||||||
|
"""
|
||||||
|
print("\nPress X to exit.")
|
||||||
|
key = getch()
|
||||||
|
if isinstance(key, bytes):
|
||||||
|
# msvcrt.getch returns type bytes, decode into str.
|
||||||
|
key = key.decode()
|
||||||
|
if key.upper() == "X":
|
||||||
|
exit()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("ib-clearance")
|
print("ib-clearance")
|
||||||
print("============")
|
print("============")
|
||||||
@ -166,13 +180,7 @@ def main():
|
|||||||
else:
|
else:
|
||||||
print("\nStudent still has lessons, clearance not granted.")
|
print("\nStudent still has lessons, clearance not granted.")
|
||||||
|
|
||||||
print("\nPress X key to exit, other key to run again.")
|
exit_sequence()
|
||||||
key = getch()
|
|
||||||
if isinstance(key, bytes):
|
|
||||||
# msvcrt.getch returns type bytes, decode into str.
|
|
||||||
key = key.decode()
|
|
||||||
if key.upper() == "X":
|
|
||||||
break
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Reference in New Issue
Block a user