예제 #1
0
 def __init_package_data(self) -> None:
     # Load package data into the Hub
     with open("../resources/wgups_package_data.csv", newline='') as package_data_file:
         reader = csv.reader(package_data_file, delimiter=',')
         # Skip header row
         next(reader, None)
         # For each package
         for row in reader:
             # Map csv row to array of proper types for easy Package initialization
             mapped_row: List[Any] = row[:]
             mapped_row[0] = int(mapped_row[0])
             mapped_row[4] = int(mapped_row[4])
             mapped_row[5] = Time(*Time.str_to_time_tuple(mapped_row[5]))
             mapped_row[6] = Time(*Time.str_to_time_tuple(mapped_row[6]))
             mapped_row[7] = float(mapped_row[7])
             mapped_row[8] = str_to_int_or_none(mapped_row[8])
             mapped_row[9] = str_to_int_or_none(mapped_row[9])
             # Create a new package object with the data
             new_package = Package(*mapped_row)
             # Store the package in the Hub for retrieval later
             self.packages.insert(new_package.id, new_package)
예제 #2
0
    # associated with the Hub, Truck, and Packages
    while True:
        view.print_logo()
        wgups_hub.print_stats()
        user_choice = parse_user_choice(input(view.main_menu))

        if user_choice == 0:  # Exit
            break
        elif user_choice == 1:  # View Hub info
            view.print_hr()
            time_filter = input(view.time_filter_prompt)

            if parse_user_choice(time_filter) == 0:  # Go back to menu
                continue
            elif Time.is_valid_time_str(time_filter):  # If valid time was entered
                time = Time(*Time.str_to_time_tuple(time_filter))

                if time < wgups_hub.start_time or time > wgups_hub.current_time:
                    print(f">> {time} is not within Today's hours of operation "
                          f"{wgups_hub.start_time} - {wgups_hub.current_time} <<")
                    View.wait_for_keypress()
                    continue

                wgups_hub.print_stats(time)
                View.wait_for_keypress()
            else:
                print(">> Invalid time entered. Ensure format matches HH:MM AM/PM (e.g., 12:24 PM) <<")
                View.wait_for_keypress()

        elif user_choice == 2:  # View Packages info
            view.print_hr()