def dispatch_task(): puts('\n' + colored.blue('-' * 80) + '\n') puts( colored.green('Preference wizard supports the following tasks:\n', bold=True)) option_descriptions = [ 'Connect a new OneDrive Personal Account', # 0 'Connect a new OneDrive for Business Account', # 1 'View / Delete connected OneDrive accounts', # 2 'Add a remote Drive to sync', # 3 'View / Edit / Delete existing Drives', # 4 'Edit global ignore list files', # 5 'Edit HTTPS proxies', # 6 'Configure synchronization workload (resync interval, etc.)', # 7 'Exit wizard' # 8 ] for i in range(0, len(option_descriptions)): puts('[{}] {}'.format(i, option_descriptions[i])) puts() task_id = prompt.query('Please enter the task index and hit [ENTER]: ', validators=[ validators.IntegerValidator(), validators.OptionValidator( range(len(option_descriptions))) ]) tasks = [ add_personal_account, add_business_account, list_existing_accounts, add_new_drive, list_existing_drives, edit_default_ignore_list, edit_proxies, edit_sync_params, bye ] if task_id < len(option_descriptions) - 1: puts('\n' + colored.blue('-' * 80) + '\n') tasks[task_id]()
def prompt_delete_account(account_list): while True: id_to_delete = prompt.query('Type the index of the account to delete: ', validators=[validators.IntegerValidator(), validators.OptionValidator(range(len(account_list)))]) account_to_delete = account_list[id_to_delete] if account_to_delete is None: puts(colored.red('Error: The account has been deleted.')) else: drive_store.delete_records_by_account(account_to_delete.profile.user_id, account_to_delete.TYPE) account_store.delete_account(account_to_delete) account_list[id_to_delete] = None puts(colored.green('Successfully deleted the account.'))
def prompt_delete_account(account_list): while True: id_to_delete = prompt.query( 'Type the index of the account to delete: ', validators=[ validators.IntegerValidator(), validators.OptionValidator(range(len(account_list))) ]) account_to_delete = account_list[id_to_delete] if account_to_delete is None: puts(colored.red('Error: The account has been deleted.')) else: account_store.delete_account(account_to_delete) account_list[id_to_delete] = None
def prompt_add_drive(drive_list): drive_count = 0 while len(drive_list) > drive_count: puts() id_to_add = prompt.query('Type the index of the Drive to add: ', validators=[validators.IntegerValidator(), validators.OptionValidator(range(len(drive_list)))]) drive_to_add = drive_list[id_to_add] if drive_to_add is None: puts(colored.red('Error: The Drive has been added.')) else: prompt_drive_config(drive_to_add) drive_list[id_to_add] = None drive_count += 1 puts(colored.green('Successfully added Drive.')) puts()
commandToFunction = { 'register': register, 'login': login, 'logout': logout, '?': printOptions, 'q': quitLearnFlow, 'status': printStatus, 'tracks': viewTracks, 'browse': browse, 'view': view, } commandList = commandOptions.keys() commandValidator = validators.OptionValidator( commandList, 'Sorry, we did not recognize that command. Type ? and hit enter for a list of available commands' ) ## # Session Data ## class SessionData: def __init__(self): self.token = '' self.__LF_Running__ = True ## # Run script
from clint.eng import join from clint.textui import puts, colored, prompt, validators import prettytable from .game import Game, Player, FlipAction, CardAction, DrawAction INIT_ACTIONS = { '1': 'Flip the top left card', '2': 'Flip the top right card', '3': 'Flip the middle left card', '4': 'Flip the middle right card', '5': 'Flip the bottom left card', '6': 'Flip the bottom right card', } INIT_ACTION_VALIDATOR = validators.OptionValidator(INIT_ACTIONS.keys()) CARD_TAKE_ACTIONS = [{ 'selector': str(index), 'prompt': message } for index, message in list(CardAction.TAKE_ACTIONS.items())] CARD_DRAW_ACTIONS = [{ 'selector': str(index), 'prompt': message } for index, message in list(CardAction.DRAW_ACTIONS.items())] CARD_WIDTH = 20 CARD_HEIGHT = 10 def main():