def show_item_details(id_item, len_items): if id_item in range(1, len_items + 1): item = register.data.get_by_id(id_item) Console.print_item_details(item) return True else: Console.notification("input", "isn't exist", "") return False
def validate_to_show_item(user_input, len_items): try: id_item = int(user_input) except ValueError: Console.notification("input", "isn't valid", "") return else: if show_item_details(id_item, len_items): go_through_items(id_item, len_items)
def prompt_menu(): actions = OrderedDict([('v', view_item), ('a', add_entry), ('b', make_backup), ('q', quit_menu)]) quit_ = False while not quit_: Console.print_banner("M E N U", '<>') Console.print_menu(actions) answer = input("> ").lower() if answer in actions: quit_ = actions[answer]() continue Console.notification("input", "not correct")
def prompt_menu(): actions = OrderedDict([ ('v', view_item), ('a', add_entry), ('b', make_backup), ('q', quit_menu) ]) quit_ = False while not quit_: Console.print_banner("M E N U", '<>') Console.print_menu(actions) answer = input("> ").lower() if answer in actions: quit_ = actions[answer]() continue Console.notification("input", "not correct")
def add_entry(): """ Add a new product to database """ item = {} for field_key in register.fileds: Console.print_banner("A D D E N T R Y", "~") Console.print_field_added(item) if field_key == "date_updated": continue if field_key == "product_price": Console.field_key_note() item[field_key] = wait_valid_input(field_key) try: register.fill_records([item]) except ValueError: Console.notification("product", "not added") else: Console.notification("product", "added successfully")
def make_backup(): """ Make a backup of the entire inventory """ if register.make_a_backup(): Console.notification("backup", "created") else: Console.notification("backup", "not created")