From 7c0b874b31df9cc368bd7b338635a3790be43957 Mon Sep 17 00:00:00 2001 From: Harsh Date: Mon, 26 Jun 2023 22:44:56 +0530 Subject: [PATCH] Path changed to Python Standards --- .../Modules/DeleteAccount/AccountDelete.py | 18 +++++++++--------- .../Modules/SignIn_Module/SignIn_page.py | 18 +++++++++--------- bus_booking_system/main.py | 8 ++++---- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/bus_booking_system/Database/Modules/DeleteAccount/AccountDelete.py b/bus_booking_system/Database/Modules/DeleteAccount/AccountDelete.py index 2ff8fec..2aa49f4 100644 --- a/bus_booking_system/Database/Modules/DeleteAccount/AccountDelete.py +++ b/bus_booking_system/Database/Modules/DeleteAccount/AccountDelete.py @@ -13,17 +13,17 @@ def write_feedback(username, feedback): # Read the current count from the file - with open("bus-booking-system\\Database\\Feedbacks\\feedbackCount.txt", "r") as count_file: + with open("bus_booking_system\\Database\\Feedbacks\\feedbackCount.txt", "r") as count_file: count = int(count_file.read()) # Increment the count by 1 count += 1 # Write the updated count back to the file - with open("bus-booking-system\\Database\\Feedbacks\\feedbackCount.txt", "w") as count_file: + with open("bus_booking_system\\Database\\Feedbacks\\feedbackCount.txt", "w") as count_file: count_file.write(str(count)) # Create the new filename using the updated count and the username - filename = "bus-booking-system\\Database\\Feedbacks\\"+str((count-1))+username+".txt" + filename = "bus_booking_system\\Database\\Feedbacks\\"+str((count-1))+username+".txt" # Write the feedback to the new file with open(filename, "w") as feedback_file: @@ -33,7 +33,7 @@ def write_feedback(username, feedback): def check_credentials(username, password): # Read the stored usernames and passwords from text files - with open('bus-booking-system\\Database\\BufferData\\CurrentUser\\username.txt', 'r') as f_username, open('bus-booking-system\\Database\\BufferData\\CurrentUser\\password.txt', 'r') as f_password: + with open('bus_booking_system\\Database\\BufferData\\CurrentUser\\username.txt', 'r') as f_username, open('bus_booking_system\\Database\\BufferData\\CurrentUser\\password.txt', 'r') as f_password: stored_usernames = f_username.read().splitlines() stored_passwords = f_password.read().splitlines() # Check if the entered credentials match any of the stored values @@ -81,7 +81,7 @@ def Feedback_dialog(self): "Help us to improve", title="Feedback Window") - with open("bus-booking-system\\Database\\BufferData\\CurrentUser\\username.txt", 'r') as file: + with open("bus_booking_system\\Database\\BufferData\\CurrentUser\\username.txt", 'r') as file: username = file.read() write_feedback(username, dialog.get_input()) @@ -102,19 +102,19 @@ def delete_line(file_path, line_to_delete): if line.strip() != line_to_delete: file.write(line) - username_file_path = 'bus-booking-system\\Database\\Modules\\SignIn_Database\\username.txt' - password_file_path = 'bus-booking-system\\Database\\Modules\\SignIn_Database\\password.txt' + username_file_path = 'bus_booking_system\\Database\\Modules\\SignIn_Database\\username.txt' + password_file_path = 'bus_booking_system\\Database\\Modules\\SignIn_Database\\password.txt' delete_line(username_file_path, entered_username) delete_line(password_file_path, entered_password) - with open("bus-booking-system\\Database\\Modules\\DeleteAccount\\DeleteTransition.txt", 'w') as file: + with open("bus_booking_system\\Database\\Modules\\DeleteAccount\\DeleteTransition.txt", 'w') as file: file.write(str(True)) self.destroy() else: print("error") - with open("bus-booking-system\\Database\\Modules\\DeleteAccount\\DeleteTransition.txt", 'w') as file: + with open("bus_booking_system\\Database\\Modules\\DeleteAccount\\DeleteTransition.txt", 'w') as file: file.write(str(False)) return messagebox.showerror('Error','Enter Correct Credentials') diff --git a/bus_booking_system/Database/Modules/SignIn_Module/SignIn_page.py b/bus_booking_system/Database/Modules/SignIn_Module/SignIn_page.py index a82b298..be75bea 100644 --- a/bus_booking_system/Database/Modules/SignIn_Module/SignIn_page.py +++ b/bus_booking_system/Database/Modules/SignIn_Module/SignIn_page.py @@ -9,10 +9,10 @@ customtkinter.set_appearance_mode("dark") - + def check_credentials(username, password): # Read the stored usernames and passwords from text files - with open('bus-booking-system\\Database\\Modules\\SignIn_Database\\username.txt', 'r') as f_username, open('bus-booking-system\\Database\\Modules\\SignIn_Database\\password.txt', 'r') as f_password: + with open('bus_booking_system\\Database\\Modules\\SignIn_Database\\username.txt', 'r') as f_username, open('bus_booking_system\\Database\\Modules\\SignIn_Database\\password.txt', 'r') as f_password: stored_usernames = f_username.read().splitlines() stored_passwords = f_password.read().splitlines() @@ -21,7 +21,7 @@ def check_credentials(username, password): if username == stored_username and password == stored_password: return True - return False + return False @@ -34,7 +34,7 @@ def __init__(self): # OPENEING WINDOW SIZE self.title("Login") self.geometry(f"{1240}x{720}") - self.bg_image = customtkinter.CTkImage(Image.open("bus-booking-system\Database\Image\Background_gradient.jpg"),size=(self.width, self.height)) + self.bg_image = customtkinter.CTkImage(Image.open("bus_booking_system\Database\Image\Background_gradient.jpg"),size=(self.width, self.height)) self.bg_image_label = customtkinter.CTkLabel(self, image=self.bg_image) self.bg_image_label.grid(row=0, column=0) @@ -87,13 +87,13 @@ def login_event(self): if check_credentials(entered_username, entered_password): self.destroy() #writing data in buffer - with open('bus-booking-system\\Database\\BufferData\\CurrentUser\\username.txt', 'w') as username: + with open('bus_booking_system\\Database\\BufferData\\CurrentUser\\username.txt', 'w') as username: username.write(str(entered_username)) - with open('bus-booking-system\\Database\\BufferData\\CurrentUser\\password.txt', 'w') as password: + with open('bus_booking_system\\Database\\BufferData\\CurrentUser\\password.txt', 'w') as password: password.write(str(entered_password)) #correct transition check value = True - with open('bus-booking-system\\Database\\Modules\\SignIn_Module\\SignIn_Check.txt', 'w') as file: + with open('bus_booking_system\\Database\\Modules\\SignIn_Module\\SignIn_Check.txt', 'w') as file: file.write(str(value)) else: @@ -112,9 +112,9 @@ def register(): password = entry_password.get() # Save username and password in text files - with open("bus-booking-system\\Database\\Modules\\SignIn_Database\\username.txt", "a") as username_file: + with open("bus_booking_system\\Database\\Modules\\SignIn_Database\\username.txt", "a") as username_file: username_file.write(username+"\n") - with open("bus-booking-system\\Database\\Modules\\SignIn_Database\\password.txt", "a") as password_file: + with open("bus_booking_system\\Database\\Modules\\SignIn_Database\\password.txt", "a") as password_file: password_file.write(password+"\n") # print("Username:", username) diff --git a/bus_booking_system/main.py b/bus_booking_system/main.py index 4b88b2d..6359938 100644 --- a/bus_booking_system/main.py +++ b/bus_booking_system/main.py @@ -18,7 +18,7 @@ def Transition_LoginToMain(): - with open("bus-booking-system\\Database\\Modules\\SignIn_Module\\SignIn_Check.txt", "r") as file: + with open("bus_booking_system\\Database\\Modules\\SignIn_Module\\SignIn_Check.txt", "r") as file: content = file.read() value = bool(content) # For debugging @@ -26,7 +26,7 @@ def Transition_LoginToMain(): if not value: exit() - with open("bus-booking-system\\Database\\Modules\\SignIn_Module\\SignIn_Check.txt", "w") as file2: + with open("bus_booking_system\\Database\\Modules\\SignIn_Module\\SignIn_Check.txt", "w") as file2: file2.truncate(0) @@ -1404,7 +1404,7 @@ def download_ticket(): # ------------------------------------------------------------------------------------------------------------- -my_img = PhotoImage(file="bus-booking-system/Database/Image/Bus_for_project.png") -home_img = PhotoImage(file="bus-booking-system/Database/Image/home.png") +my_img = PhotoImage(file="bus_booking_system/Database/Image/Bus_for_project.png") +home_img = PhotoImage(file="bus_booking_system/Database/Image/home.png") tab1() root.mainloop()