def import_deck(stdscr, user): search_term = get_user_input(stdscr, 'Search term (ESC to accept)') objects = SharedDeck.objects(name__icontains=search_term) choice = choice_window('Which one do you choose?', [(d.name, d.description) for d in objects], stdscr) if choice >= 0: chosen = objects[choice] user.import_deck(chosen)
def unfollow(self): email = get_user_input("Insert User Email") if email in self.following: del self.following[email] print_info("Success: Unfollowed " + email) else: print_info("Failure: Not following " + email)
def follow(self): email = get_user_input("Insert User Email") if email in self.following: print_info("Failures: Already following " + email) else: self.following[email] = 0 print_info("Success: Now following " + email)
def make_post(self): text = get_user_input("Write New Post: ") post = {"from": self.email, \ "id": self.id, \ "date": datetime.now().strftime("%y/%m/%d %H:%M:%S"), \ "text": text} self.my_posts.append(post) self.id += 1 return post
def main(): user_input = get_user_input() queue = multiprocessing.Queue() targets = [prod_acc, prod_gps] kwargss = [{"period": 0.2}, {"period": 0.2}] _launch_producers(queue, targets, kwargss) timeout = 0.1 max_get_attemps = 3 _launch_consumer(queue, user_input, timeout, max_get_attemps)
def main(): calendar = initialize_calendar() while True: ui.print_menu() user_choice = ui.get_user_input('Enter choice', str) if user_choice == 's': schedule_meeting_in(calendar) elif user_choice == 'c': pass elif user_choice == 'q': break else: ui.print_message('No such option!')
def main(): while True: file_name = 'schedule.csv' menu_list = { '(s)': 'schedule a new meeting', '(e)': 'edit a meeting', '(c)': 'cancel a meeting', '(q)': 'quit' } ui.print_schedule(file_name) ui.print_menu(menu_list) user_answers = ui.get_user_input([''], "Make a choice:") try: choose(user_answers, file_name) except KeyError as err: print(str(err))
def handle_user(stdscr): while True: credentials = get_login_credentials(stdscr) email = credentials[0] password = credentials[1] try: return login_user(email, password) except NoSuchUserException: try: username = get_user_input( stdscr, 'You are creating a new account. Choose your new username') return register_user(username, email, password) except mongoengine.errors.ValidationError: show_message(stdscr, "{} is not a correct email address".format(email)) continue except IncorrectPasswordException: show_message(stdscr, "Incorrect password") continue
def schedule_a_new_meeting(file_name): os.system('clear') print( "Schedule a new meeting.\n 'Give title, duration and start time of the meeting: " ) user_data = ui.get_user_input([ 'Enter meeting title: ', 'Enter duration in hours (1 or 2): ', 'Enter start time: ' ], "") converted_user_input = scripts.convert_user_input( user_data) # Validate and convert user input is_working_time = scripts.is_working_time( converted_user_input) # is meeting in workhours is_duration_valid = scripts.is_duration( converted_user_input) # is duration is 1 ot 2 hour is_time_free = scripts.is_time_free(converted_user_input, file_name) if converted_user_input and is_working_time and is_duration_valid and is_time_free: storage.write_data_to_file(file_name, user_data) else: input('inappropriate time. Press enter to try again...') schedule_a_new_meeting(file_name)
def show_menu(stdscr, deck_i: int, user: User): deck = list(user.decks)[deck_i] options = list( filter(lambda x: x is not None, [ 'study', 'edit', 'share' if deck.size > 0 else None, 'delete', 'cancel' ])) choice = options[choice_window(deck.name, options, stdscr)] if choice == 'delete': user.drop_deck(deck_i) elif choice == 'edit': deck_edit_screen(stdscr, DeckCreationWizard(user, deck)) user.save() elif choice == 'study': study_deck(stdscr, deck, user) elif choice == 'cancel': pass elif choice == 'share': description = get_user_input(stdscr, "{} deck description".format(deck.name)) deck.share(user, description)
def edit_a_meeting(file_name, edit_mode="cancell"): print("Cancel an existing meeting.\n") user_time = ui.get_user_input(['Enter the start time: '], "") meeting_time_to_change = str(user_time[0]) schedules_list = storage.get_data_from_file(file_name) schedules_list_after_editing = [] if_meeting_exists = False for meeting in schedules_list: start_time = meeting[2] if meeting_time_to_change == str( start_time) and edit_mode == "cancell": if_meeting_exists = True continue schedules_list_after_editing.append(meeting) if not if_meeting_exists: print( f"ERROR: There is no meeting starting at the {time_to_delete} o'clock" ) input('Press enter to continue...') os.system('clear') edit_a_meeting(file_name) storage.write_data_to_file(file_name, schedules_list_after_editing, False)
def main(stdscr): stdscr.keypad(True) curses.cbreak() curses.start_color() curses.init_pair(1, curses.COLOR_BLUE, curses.COLOR_BLACK) curses.init_pair(2, curses.COLOR_BLUE, curses.COLOR_BLACK) curses.init_pair(5, curses.COLOR_WHITE, curses.COLOR_BLACK) curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK) curses.init_pair(4, curses.COLOR_GREEN, curses.COLOR_BLACK) curses.noecho() user = handle_user(stdscr) print(user.username) while True: choice = choice_window('Your decks:', user.get_decks_names(), stdscr, { 'n': -10, 'i': -11 }, [ '\'n\' to create new deck, \'i\' to search for shared decks', '\'q\' to exit' ]) if choice >= 0: show_menu(stdscr, choice, user) elif choice == -10: name = get_user_input(stdscr, 'Nazwa nowej talii') deck_edit_screen(stdscr, user.create_new_deck(name)) user.save() elif choice == -11: import_deck(stdscr, user) elif choice == -1: break else: break user.save()
def schedule_meeting_in(calendar): meeting_title = ui.get_user_input('Enter meeting title', str) duration = ui.get_user_input('Enter duration in hours (1 or 2)', int, 'duration') start_time = ui.get_user_input('Enter start time', int, 'start_time') print(duration, start_time, meeting_title)
def main(): Locations.make_list_of_objects() while True: ui.print_menu() option = ui.get_user_input('Choose option: ') if option == '1': ui.display_statistic() ui.get_user_input('\nPress any key to back.') continue elif option == '2': ui.display_3longest_city_names() ui.get_user_input('\nPress any key to back.') continue elif option == '3': ui.display_county_name() ui.get_user_input('\nPress any key to back.') continue elif option == '4': # print(Locations.many_categories()) ui.dispaly_meny_categories_locations() ui.get_user_input('\nPress any key to back.') continue elif option == '5': ui.dispaly_searching() ui.get_user_input('\nPress any key to back.') elif option == '0': sys.exit()