def __search(): res = 0 __show_groups() while not res: group_id = raw_input(strings.input_id) res = __validate_int(group_id) if res: if not __groups_lab.get_groups().has_key(int(group_id)): print strings.wrong_input res = 0 else: group = __groups_lab.get_groups().get(int(group_id)) data = __students_lab.get_students() youngest = 0 for key in data.keys(): if int(data[key].get_group_id()) == int(group.get_id()): if youngest == 0: youngest = data[key] if data[key].get_age() < youngest.get_age(): youngest = data[key] if youngest != 0: gui.clean() gui.print_title_students() gui.print_student(youngest) return else: print strings.error_student_not_found
def __change_student(): res = 0 __show_students() while not res: student_id = raw_input(strings.input_id) res = __validate_int(student_id) if res: if not __students_lab.get_students().has_key(int(student_id)): print strings.wrong_input res = 0 else: student = __students_lab.get_students().get(int(student_id)) gui.clean() while 1: gui.print_student_change_menu() choices_menu = raw_input(strings.choice_hint) try: choices_menu = int(choices_menu) if choices_menu == 1: gui.clean() student.set_name(raw_input(strings.input_name)) gui.successful_message() continue elif choices_menu == 2: gui.clean() student.set_age(raw_input(strings.input_age)) gui.successful_message() continue elif choices_menu == 3: gui.clean() __show_groups() student.set_group_id( raw_input(strings.input_group_id)) gui.successful_message() continue elif choices_menu == 4: gui.clean() break else: print(strings.wrong_input) except ValueError: print(strings.wrong_input)
def __change_film(): res = 0 __show_films() while not res: film_id = raw_input(strings.input_id) res = __validate_int(film_id) if res: if not __films_lab.get_films().has_key(int(film_id)): print strings.wrong_input res = 0 else: film = __films_lab.get_films().get(int(film_id)) gui.clean() while 1: gui.print_producer_change_menu() choices_menu = raw_input(strings.choice_hint) try: choices_menu = int(choices_menu) if choices_menu == 1: gui.clean() film.set_name(raw_input(strings.input_name)) gui.successful_message() continue elif choices_menu == 2: gui.clean() film.set_location(raw_input( strings.input_location)) gui.successful_message() continue elif choices_menu == 3: gui.clean() film.set_date(raw_input(strings.input_date)) gui.successful_message() continue elif choices_menu == 4: gui.clean() break else: print(strings.wrong_input) except ValueError: print(strings.wrong_input)
def __change_producer(): res = 0 __show_producers() while not res: producer_id = raw_input(strings.input_id) res = __validate_int(producer_id) if res: if not __producers_lab.get_producers().has_key(int(producer_id)): print strings.wrong_input res = 0 else: producer = __producers_lab.get_producers().get( int(producer_id)) gui.clean() while 1: gui.print_producer_change_menu() choices_menu = raw_input(strings.choice_hint) try: choices_menu = int(choices_menu) if choices_menu == 1: gui.clean() producer.set_name(raw_input(strings.input_name)) gui.successful_message() continue elif choices_menu == 2: gui.clean() producer.set_age(raw_input(strings.input_age)) gui.successful_message() continue elif choices_menu == 3: gui.clean() producer.set_sex(raw_input(strings.input_sex)) gui.successful_message() continue elif choices_menu == 4: gui.clean() break else: print(strings.wrong_input) except ValueError: print(strings.wrong_input)
def __menu(): gui.print_menu() while 1: choices = raw_input(strings.choice_hint) try: choices = int(choices) if choices == 1: gui.clean() __add_producer() gui.successful_message() __menu() break elif choices == 2: gui.clean() if __producers_lab.size() > 0: __add_film() gui.successful_message() else: gui.error_message(strings.error_add_new_film) __menu() break elif choices == 3: gui.clean() if __producers_lab.size() > 0: __show_producers() gui.successful_message() else: gui.error_message(strings.not_found_data) __menu() break elif choices == 4: gui.clean() if __films_lab.size() > 0: __show_films() gui.successful_message() else: gui.error_message(strings.not_found_data) __menu() break elif choices == 5: gui.clean() __search() gui.successful_message() __menu() break elif choices == 6: gui.clean() if __producers_lab.size() > 0: __change_producer() else: gui.error_message(strings.not_found_data) __menu() break elif choices == 7: gui.clean() if __films_lab.size() > 0: __change_film() gui.successful_message() else: gui.error_message(strings.not_found_data) __menu() break elif choices == 8: gui.clean() if __producers_lab.size() > 0: __show_producers() if __del_producer(): gui.clean() __show_producers() print strings.producer_film_del_message gui.successful_message() else: gui.error_message(strings.error_user_not_found) else: gui.error_message(strings.not_found_data) __menu() break elif choices == 9: gui.clean() if __films_lab.size() > 0: __show_films() if __del_film(): gui.clean() __show_films() gui.successful_message() else: gui.error_message(strings.error_film_not_found) else: gui.error_message(strings.not_found_data) __menu() break elif choices == 0: file.save_producers(__producers_lab.get_producers()) file.save_films(__films_lab.get_films()) break else: print(strings.wrong_input) except ValueError: print(strings.wrong_input)
def main(): gui.clean() __menu()
def __menu(): gui.print_menu() while 1: choices = raw_input(strings.choice_hint) try: choices = int(choices) if choices == 1: gui.clean() __add_producer() gui.successful_message() __menu() break elif choices == 2: gui.clean() if __groups_lab.size() > 0: __add_student() gui.successful_message() else: gui.error_message(strings.error_add_new_student) __menu() break elif choices == 3: gui.clean() if __groups_lab.size() > 0: __show_groups() gui.successful_message() else: gui.error_message(strings.not_found_data) __menu() break elif choices == 4: gui.clean() if __students_lab.size() > 0: __show_students() gui.successful_message() else: gui.error_message(strings.not_found_data) __menu() break elif choices == 5: gui.clean() __search() gui.successful_message() __menu() break elif choices == 6: gui.clean() if __groups_lab.size() > 0: __change_group() else: gui.error_message(strings.not_found_data) __menu() break elif choices == 7: gui.clean() if __students_lab.size() > 0: __change_student() gui.successful_message() else: gui.error_message(strings.not_found_data) __menu() break elif choices == 8: gui.clean() if __groups_lab.size() > 0: __show_groups() if __del_group(): gui.clean() __show_groups() print strings.group_student_del_message gui.successful_message() else: gui.error_message(strings.error_group_not_found) else: gui.error_message(strings.not_found_data) __menu() break elif choices == 9: gui.clean() if __students_lab.size() > 0: __show_students() if __del_student(): gui.clean() __show_students() gui.successful_message() else: gui.error_message(strings.error_student_not_found) else: gui.error_message(strings.not_found_data) __menu() break elif choices == 0: __groups_lab.save_groups() __students_lab.save_students() break else: print(strings.wrong_input) except ValueError: print(strings.wrong_input)