Exemplo n.º 1
0
def show_questions(anime_list):
    style = style_from_dict({
        Token.Separator: '#6C6C6C',
        Token.QuestionMark: '#FF9D00 bold',
        #Token.Selected: '',  # default
        Token.Selected: '#5F819D',
        Token.Pointer: '#FF9D00 bold',
        Token.Instruction: '',  # default
        Token.Answer: '#5F819D bold',
        Token.Question: '',
    })
    questions = [
        {
            'type': 'list',
            'name': 'anime_title',
            # TODO remove this hard code
            'message':
            'This is top ten anime in summer 2018, which anime that you want to see detail?',
            'choices': map(_get_title)(anime_list)
        },
    ]
    answers = prompt(questions, style=style)
    pp = pprint.PrettyPrinter(indent=1)
    pipe(answers, lambda answers: answers['anime_title'],
         _get_anime_by_title(anime_list), pp.pprint)
Exemplo n.º 2
0
def main_menu():
    style = style_from_dict({
        Token.Separator: '#cc5454',
        Token.QuestionMark: '#673ab7 bold',
        Token.Selected: '#cc5454',  # default
        Token.Pointer: '#673ab7 bold',
        Token.Instruction: '',  # default
        Token.Answer: '#f44336 bold',
    })

    option1 = 'Enter a Book Name'
    option2 = 'Upload a file with Book Names'

    questions = [
                  {
                    'type': 'list',
                    'message': '',
                    'name': 'option',
                    'choices':  [
                                  Separator('How do you want to add your book/s to Goodread?'),
                                    {
                                      'name': option1
                                    },
                                    {
                                      'name': option2
                                    },
                                ],
                    'validate': lambda answer: 'You must choose at least one.' \
                        if len(answer) == 0 else True
                  }
                ]
    answers = prompt(questions, style=style)
    return answers['option']
Exemplo n.º 3
0
 def __init__(self):
     self.privilege = {
         0: "admin",
         1: "data_scientist",
         2: "geographe",
         3: "consultant"
     }
     self.reversed_privilege = {
         value: key
         for (key, value) in self.privilege.items()
     }
     self.menu_ref = {'-> create an account':[[0], 'signup'], '-> login':[[3], 'signin'],\
     '-> display a country':[[0,1,2,3], 'display_country'], '-> propose a correction' : [[1,3], 'correction'],\
     '-> review corrections':[[0,2], 'review'], '-> add/modify a country' : [[0,2], 'modify_country'],\
     '-> remove a country' : [[0], 'remove_country'], '-> display histogramme' : [[0,1], 'plot_hist'],\
     '-> display boxplot' : [[0,1], 'plot_boxplot'], '-> remove an account' : [[0], 'remove_account'], "-> logout":[[0,1,2], 'logout'], "-> exit":[[0,1,2,3], 'sys_exit']}
     self.field_names = ["country_name", "superficie", "population", "croissance_demo", "inflation", "dette", "taux_chomage",\
      "taux_depense_sante", "taux_depense_educ", "taux_depense_militaire"]
     self.style = style_from_dict({
         Token.QuestionMark: '#E91E63 bold',
         Token.Selected: '#673AB7 bold',
         Token.Instruction: '',  # default
         Token.Answer: '#2196f3 bold',
         Token.Question: '',
     })
     tmp_obj = db_handler("factbook")
     resp_ = tmp_obj.sql_run("SELECT * FROM factbook;")
     if not len(resp_):
         from load_factbook import factbook_processor
         obj_ = factbook_processor()
         obj_.insert_db()
Exemplo n.º 4
0
def menu(dir):
    style = style_from_dict({
        Token.Separator: '#cc5454',
        Token.QuestionMark: '#673ab7 bold',
        Token.Selected: '#cc5454',  # default
        Token.Pointer: '#673ab7 bold',
        Token.Instruction: '',  # default
        Token.Answer: '#f44336 bold',
        Token.Question: '',
    })

    filesArray = formatFileArray(getFiles('../onhold'))

    # filter files array to only .ogg files

    separatorList = np.array([Separator('= Choose a Song: =')])

    choices = np.concatenate((separatorList, filesArray))

    questions = [
        {
            'type': 'checkbox',
            'message': 'Select song',
            'name': 'songs',
            'choices': choices,
            'validate': lambda answer: 'You must choose a song.' \
                if len(answer) == 0 else True
        }
    ]

    answers = prompt(questions, style=style)
    return answers
Exemplo n.º 5
0
def take_email_input():
    check = '^[a-z0-9]+[\._]?[a-z0-9]+@\w+\.\w{2,3}$'
    custom_style_2 = style_from_dict({
        Token.Separator:
        '#6C6C6C',
        Token.QuestionMark:
        '#FFFFFF bold',
        # Token.Selected: '',  # default
        Token.Selected:
        '#5F819D',
        Token.Pointer:
        '#FF9D00 bold',
        Token.Instruction:
        '',  # default
        Token.Answer:
        '#5F819D bold',
        Token.Question:
        '#FFA500',
    })
    questions = [{
        'type': 'input',
        'name': 'email',
        'message': "What is the target's email-id:",
    }]
    ran_once_unsuccessfully = False
    target_email = ""
    while not re.search(check, target_email):
        if ran_once_unsuccessfully:
            print(printing.colors.fg.yellow, "Invalid email please try again")
        target_email = prompt(questions, style=custom_style_2)['email']
        ran_once_unsuccessfully = True

    return target_email
Exemplo n.º 6
0
class Enum():
    style = style_from_dict({
        Token.QuestionMark: '#E91E63 bold',
        Token.Selected: '#673AB7 bold',
        Token.Instruction: '',  # default
        Token.Answer: '#2196f3 bold',
        Token.Question: '',
    })
Exemplo n.º 7
0
    def refresh_style(self):
        """Refresh the actual style from the current style dictionary.

        Args:
            None

        """
        self.style = style_from_dict(self.style_dict)
Exemplo n.º 8
0
    def __init__(self):

        self.style = style_from_dict({
            Token.QuestionMark: '#E91E63 bold',
            Token.Selected: '#673AB7 bold',
            Token.Instruction: '',  # default
            Token.Answer: '#2196f3 bold',
            Token.Question: '',
        })
Exemplo n.º 9
0
 def ask_pawn(self, pawns):
     question = [{
         'type': 'list',
         'name': 'pawn',
         'message': "Please choose a pawn to move : ",
         'choices': pawns,
         'filter': lambda val: pawns.index(val)
     }]
     return prompt(question, style=style_from_dict(get_style()))['pawn']
Exemplo n.º 10
0
 def ask_movement(self, possible_moves):
     question = [{
         'type': 'list',
         'name': 'move',
         'message': 'Please choose a posible move : ',
         'choices': possible_moves,
         'filter': lambda val: possible_moves.index(val)
     }]
     return prompt(question, style=style_from_dict(get_style()))['move']
Exemplo n.º 11
0
 def __init__(self):
     self.style = style_from_dict({
         Token.Separator: '#CC5454',
         Token.QuestionMark: '#BCBBBB bold',
         Token.Selected: '#FF5700',  # default
         Token.Pointer: '#FF5700 bold',
         Token.Instruction: '',  # default
         Token.Answer: '#FF5700 bold',
         Token.Question: '',
     })
Exemplo n.º 12
0
 def __init__(self):
     self.style = style_from_dict({
         Token.QuestionMark: '#fac731 bold',
         Token.Answer: '#06c8ff bold',
         Token.Instruction: '',  # default
         Token.Separator: '#cc5454',
         Token.Selected: '#0abf5b',  # default
         Token.Pointer: '#673ab7 bold',
         Token.Question: '',
     })
Exemplo n.º 13
0
def style():
    return style_from_dict({
        Token.QuestionMark: "#fac731 bold",
        Token.Answer: "#4688f1 bold",
        Token.Instruction: "",  # default
        Token.Separator: "#cc5454",
        Token.Selected: "#0abf5b",  # default
        Token.Pointer: "#673ab7 bold",
        Token.Question: "",
    })
Exemplo n.º 14
0
def make_style(color):
    return style_from_dict({
        Token.Separator: color,
        Token.QuestionMark: '#673ab7 bold',
        Token.Selected: color,  # default
        Token.Pointer: '#673ab7 bold',
        Token.Instruction: '',  # default
        Token.Answer: '#f44336 bold',
        Token.Question: '',
    })
Exemplo n.º 15
0
class Common(object):
    style = style_from_dict({
        Token.Separator: '#cc5454',
        Token.QuestionMark: '#673ab7 bold',
        Token.Selected: '#cc5454',  # default
        Token.Pointer: '#FFFFCC bold',
        Token.Instruction: '',  # default
        Token.Answer: '#f44336 bold',
        Token.Question: '',
    })
Exemplo n.º 16
0
def initialize_project():

    style = style_from_dict({
        Token.QuestionMark: '#E91E63 bold',
        Token.Selected: '#673AB7 bold',
        Token.Instruction: '',  # default
        Token.Answer: '#2196f3 bold',
        Token.Question: '',
    })

    questions = [
        {
            'type': 'input',
            'name': 'name',
            'message': 'Package name:',
            'default': 'qwe'
        },
        {
            'type': 'input',
            'name': 'version',
            'message': 'Version:',
            'default': '1.0.0',
        },
        {
            'type': 'input',
            'name': 'description',
            'message': 'Description:',
            'default': '',
        },
        {
            'type': 'input',
            'name': 'repository',
            'message': 'Repository:',
        },
        {
            'type': 'input',
            'name': 'author',
            'message': 'Author:',
        },
        {
            'type': 'input',
            'name': 'keywords',
            'message': 'Keywords:',
        },
        {
            'type': 'input',
            'name': 'license',
            'message': 'License:',
        },

    ]
    answers = prompt(questions, style=style)
    if answers:
        with open('app.json', 'w') as config:
            json.dump(answers, config, indent=4)
Exemplo n.º 17
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.style = style_from_dict({
         Token.Separator: '#cc5454',
         Token.QuestionMark: '#673ab7 bold',
         Token.Selected: '#cc5454',  # default
         Token.Pointer: '#673ab7 bold',
         Token.Instruction: '',  # default
         Token.Answer: '#f44336 bold',
         Token.Question: '',
     })
Exemplo n.º 18
0
def styler():
    style = style_from_dict({
        Token.Separator: '#cc5454',
        Token.QuestionMark: '#ff1f17',
        Token.Selected: '#cc5454',  # default
        Token.Pointer: '#673ab7 bold',
        Token.Instruction: '#f44336 bold',  # default
        Token.Answer: '#ccf5ff',
        Token.Question: '#21ed39',
    })
    return style
Exemplo n.º 19
0
def get_styles():
    custom_style = style_from_dict({
        Token.Separator: '#66a6c3 bold',
        Token.QuestionMark: '#ff0000 bold',
        Token.Selected: '#cc5454',  # default
        Token.Pointer: '#673ab7 bold',
        Token.Instruction: 'bold',  # default
        Token.Answer: '#66a6c3 bold',
        Token.Question: 'bold',
    })
    return custom_style
Exemplo n.º 20
0
def choose_devices(devices, query=False):
    """
    Create list of menu choices from devices with category separators
    Optional param query: query and display device version numbers
    """
    # Style for selection interface
    style = style_from_dict({
        Token.Separator: '#FF00AA',
        Token.QuestionMark: '#00AAFF bold',
        Token.Selected: '#00AAFF',  # default
        Token.Pointer: '#00FF00 bold',
        Token.Instruction: '#FFAA00',  # default
        Token.Answer: '#00AAFF bold',
        Token.Question: '#FF00AA',
    })

    choice_list = []
    current_type = None
    name_len = max([len(dev.f_name) for dev in devices]) + 1

    if query:
        print('Querying all devices for version numbers. '
              'This may take a minute...')
        choice_list.append(
            Separator('Name'.center(name_len) + 'Firmware'.center(15) +
                      'Core'.center(7) + 'State'))
    for device in devices:
        if device.type != current_type:
            current_type = device.type
            sep_str = ' {} '.format(current_type).center(name_len + 29, '=')
            choice_list.append(Separator(sep_str))
        menu_text = device.f_name.ljust(name_len)
        if query and device.software == 'tasmota':
            device.query_tas_status()
            if 'tas_version' in device.reported:
                menu_text += device.reported['tas_version'].ljust(15)
                menu_text += device.reported['core_version'].ljust(7)
                if device.reported['power'] is not None:
                    menu_text += device.reported['power']
            else:
                menu_text += 'Offline'
        choice_list.append({'name': menu_text, 'value': device.f_name})

    # Ask the user to choose which devices to flash
    questions = [{
        'type': 'checkbox',
        'message': 'Select Devices',
        'name': 'device_selection',
        'choices': choice_list,
    }]
    answers = prompt(questions, style=style)
    selected_devices = [device for device in devices if device.f_name \
                        in answers['device_selection']]
    return selected_devices
Exemplo n.º 21
0
def get_default_style():
    style = style_from_dict({
        Token.Separator: '#cc5454',
        Token.QuestionMark: '#673ab7 bold',
        Token.Selected: '#cc5454',  # default
        Token.Pointer: '#673ab7 bold',
        Token.Instruction: '',  # default
        Token.Answer: '#f44336 bold',
        Token.Question: '',
    })
    return style
Exemplo n.º 22
0
def ask_file(files, student, spec, basedir):
    style = style_from_dict({
        Token.QuestionMark: '#e3bd27 bold',
        Token.Selected: '#e3bd27',
        Token.Pointer: '#e3bd27 bold',
        Token.Answer: '#e3bd27 bold',
    })

    while True:
        questions = [
            {
                'type': 'list',
                'name': 'file',
                'message': 'Choose file',
                'choices': ['BACK'] + files,
            }
        ]
        file = prompt(questions, style=style)

        if file and file['file'] != 'BACK':
            file_spec = {}
            for f in spec['files']:
                if f['filename'] == file['file']:
                    file_spec = f
                    break
            if file_spec:
                with chdir('{}/{}'.format(student, spec['assignment'])):
                    # prepare the current folder
                    inputs = spec.get('inputs', [])
                    supporting = os.path.join(basedir, 'data', 'supporting')
                    # write the supporting files into the folder
                    for filename in inputs:
                        with open(os.path.join(supporting, spec['assignment'], filename), 'rb') as infile:
                            contents = infile.read()
                        with open(os.path.join(os.getcwd(), filename), 'wb') as outfile:
                            outfile.write(contents)
                    process_file(file_spec['filename'],
                                 steps=file_spec['commands'],
                                 options=file_spec['options'],
                                 spec=spec,
                                 cwd=os.getcwd(),
                                 supporting_dir=os.path.join(basedir, 'data', 'supporting'),
                                 interact=False,
                                 basedir=basedir,
                                 spec_id=spec['assignment'],
                                 skip_web_compile=False)
                    # and we remove any supporting files
                    try:
                        for inputfile in inputs:
                            os.remove(inputfile)
                    except FileNotFoundError:
                        pass
        else:
            return
Exemplo n.º 23
0
def prompt_checkbox(choices="", style="", message="", name="", validator=""):
    choices = ([
        Separator("= The Meats ="),
        {
            "name": "Ham"
        },
        {
            "name": "Ground Meat"
        },
        Separator("= The Cheeses ="),
        {
            "name": "Mozzarella",
            "checked": True
        },
        Separator("= The usual ="),
        {
            "name": "Mushroom"
        },
        Separator("= The extras ="),
        {
            "name": "Olives",
            "disabled": "out of stock"
        },
    ] if not choices else choices)

    style = (
        style_from_dict({
            Token.Separator: "#cc5454",
            Token.QuestionMark: "#673ab7 bold",
            Token.Selected: "#cc5454",  # default
            Token.Pointer: "#673ab7 bold",
            Token.Instruction: "",  # default
            Token.Answer: "#f44336 bold",
            Token.Question: "",
        }) if not style else style)

    message = "message" if not message else message
    name = "repos" if not name else name
    validator = ((lambda answer: "You must choose at least one."
                  if len(answer) == 0 else True)
                 if not validator else validator)

    questions = [{
        "type": "checkbox",
        "message": message,
        "name": name,
        "choices": choices,
        "validate": validator,
    }]

    answers = prompt(questions, style=style)
    return answers
Exemplo n.º 24
0
 def __init__(self, message, choices, name):
     self.message = message
     self.choices = choices
     self.name = name
     self.style = style_from_dict({
         Token.Separator: '#cc5454',
         Token.QuestionMark: '#673ab7 bold',
         Token.Selected: '#cc5454',  # default
         Token.Pointer: '#673ab7 bold',
         Token.Instruction: '',  # default
         Token.Answer: '#f44336 bold',
         Token.Question: '',
     })
Exemplo n.º 25
0
 def run_menu(self) -> None:
     choices: List = self.create_choices()
     questions: List = self.create_questions(choices)
     while True:
         answers = prompt(questions, style=style_from_dict(self.style))
         if 'all' in answers['Modules'] or self.validation_func(
                 answers['Modules']):
             break
         else:
             os.system('cls' if os.name == 'nt' else 'clear')
             print(self.validation_error)
     self.parse_menu_args(answers['Modules'])
     self.decide_action()
Exemplo n.º 26
0
def cli():

    text = "Protomate"
    ascii_banner = figlet_format(text, font="standard")
    cprint(ascii_banner, "cyan", attrs=["bold"])

    style = style_from_dict({
        Token.QuestionMark: "#E91E63 bold",
        Token.Answer: "#fac731 bold",
        Token.Instruction: "#ef8a62",
        Token.Separator: "#cc5454",
        Token.Selected: "#7fc97f",
        Token.Pointer: "#fdc086",
        Token.Question: "",
    })

    questions = [{
        "type": "input",
        "name": "github_username",
        "message": "GitHub Username:"******"type": "password",
        "name": "github_password",
        "message": "GitHub Password:"******"type": "input",
        "name": "repo_name",
        "message": "Repository Name:"
    }, {
        "type": "list",
        "name": "repo_type",
        "message": "Repository Type:",
        "choices": ["Public", "Private"],
    }, {
        "type":
        "input",
        "name":
        "gitignore",
        "message":
        "(Optional) Please enter language name to create .gitignore file, press enter if you don't want."
    }]

    answers = prompt(questions, style=style)

    github_username = answers["github_username"]
    github_password = answers["github_password"]
    repo_name = answers["repo_name"]
    repo_type = answers["repo_type"]
    gitignore = answers["gitignore"]

    return github_username, github_password, repo_name, repo_type, gitignore
Exemplo n.º 27
0
def mark_done(project=None, done=None):
    style = style_from_dict({
        Token.Separator: '#cc5454',
        Token.QuestionMark: '#673ab7 bold',
        Token.Selected: '#cc5454',  # default
        Token.Pointer: '#673ab7 bold',
        Token.Instruction: '',  # default
        Token.Answer: '#f44336 bold',
        Token.Question: '',
    })

    if project is None:
        notes_path = os.getenv('notes')
    else:
        notes_path = os.path.join(os.getenv(project), 'notes/')

    if done is None:
        matches = get_todos(notes_path)
        choices = [Separator('= TODO =')]
        for match in matches:
            choices.append({'name': match.get('task')})
        questions = [
            {
                'type': 'checkbox',
                'message': 'Select complete task',
                'name': 'tasks',
                'choices': choices,
                'validate': lambda answer: 'You must complete at least 1 task' \
                    if len(answer) == 0 else True
            }
        ]

        answers = prompt(questions, style=style)
        if not answers:
            sys.exit(0)
        for answer in answers['tasks']:
            for match in matches:
                if answer == match['task']:
                    updated_task = match['task'].replace(
                        '#TODO[ ]:', '#TODO[X]:')
                    with open(match['filepath'], 'r') as handle:
                        lines = handle.readlines()
                    with open(match['filepath'], 'w') as handle:
                        for line in lines:
                            if match['task'] in line:
                                handle.write(updated_task + '\n')
                            else:
                                handle.write(line)
                        print('Updated {}'.format(match['filepath']))
Exemplo n.º 28
0
def obtainDecision():

    style = style_from_dict({
        Token.Separator: '#6C6C6C',
        Token.QuestionMark: '#FF9D00 bold',
        Token.Selected: '#5F819D',
        Token.Pointer: '#FF9D00 bold',
        Token.Answer: '#5F819D bold',
    })

    dataset_question = [{
        'type':
        'checkbox',
        'name':
        'chosen',
        'message':
        'Select all datasets you want to download:',
        'choices': [{
            'name': 'COVID19 Subsidies'
        }, {
            'name': 'Laws'
        }, {
            'name': 'House of Representatives Sessions (Diputados)'
        }, {
            'name': 'List of Representatives (Diputados)'
        }]
    }]

    dataset_answer = prompt(dataset_question, style=style)

    confirmation_question = [{
        'type':
        'confirm',
        'message':
        'Should we go forward with these datasets?: {}'.format(
            str(dataset_answer['chosen'])[1:-1]),
        'name':
        'confirmation',
        'default':
        True,
    }]
    confirmation_answer = prompt(confirmation_question, style=style)

    if confirmation_answer['confirmation'] is False:
        print('Ok, exiting...')
        quit()

    return (dataset_answer['chosen'])
Exemplo n.º 29
0
def prompt_list(choices="", style="", message="", name="", default=""):
    choices = ([
        Separator("= The Meats ="),
        {
            "name": "Ham"
        },
        {
            "name": "Ground Meat"
        },
        Separator("= The Cheeses ="),
        {
            "name": "Mozzarella",
            "checked": True
        },
        Separator("= The usual ="),
        {
            "name": "Mushroom"
        },
        Separator("= The extras ="),
        {
            "name": "Olives",
            "disabled": "out of stock"
        },
    ] if not choices else choices)

    style = (
        style_from_dict({
            Token.Separator: "#cc5454",
            Token.QuestionMark: "#673ab7 bold",
            Token.Selected: "#cc5454",  # default
            Token.Pointer: "#673ab7 bold",
            Token.Instruction: "",  # default
            Token.Answer: "#f44336 bold",
            Token.Question: "",
        }) if not style else style)

    message = "message" if not message else message
    name = "environment" if not name else name

    questions = [{
        "type": "list",
        "message": message,
        "name": name,
        "choices": choices,
    }]

    answers = prompt(questions, style=style)
    return answers
Exemplo n.º 30
0
    def __askDate(self):

        style = style_from_dict({Token.QuestionMark: '#fac731 bold',
                                Token.Answer: '#4688f1 bold',
                                Token.Instruction: '',  # default
                                Token.Separator: '#cc5454',
                                Token.Selected: '#0abf5b',  # default
                                Token.Pointer: '#673ab7 bold',
                                Token.Question: '',
        })

        Questions = [
        {
            'type':'input',
            'name':'ano',
            'message':'Qual o ano da pesquisa:'

        },
        {
            'type':'input',
            'name':'diaInicial',
            'message':'Dia inicial:',
            
        },
        {
            'type':'input',
            'name':'mesInicial',
            'message':'Mes Inicial:'
        },
        {
            'type':'input',
            'name':'diaFinal',
            'message':'Dia Final:'
        },
        {
            'type':'input',
            'name':'mesFinal',
            'message':'Mes Final:'
        }
        ]

        answer = prompt(Questions,style = style)

        dataInit = str(answer['ano']) + '-' + str(answer['mesInicial']) + '-' + str(answer['diaInicial'])
        dataFim = str(answer['ano']) +  '-' + str(answer['mesFinal']) + '-' + str(answer['diaFinal'])

        return dataInit,dataFim
Exemplo n.º 31
0
def main():
    f = FtpXsales()

    #conexion con el dz
    f.Login()

    style = style_from_dict({
        Token.Separator: '#cc5454',
        Token.QuestionMark: '#673ab7 bold',
        Token.Selected: '#cc5454',  # default
        Token.Pointer: '#673ab7 bold',
        Token.Instruction: '',  # default
        Token.Answer: '#f44336 bold',
        Token.Question: '',
    })

    questions = [{
        'type': 'confirm',
        'name': 'Consulta',
        'message': 'Deseas revisar todas las rutas?',
    }, {
        'type': 'checkbox',
        'name': 'Rutas',
        'message': 'Seleciona las rutas que deseas revisar',
        'choices': f.parseandorutas(),
        'when': lambda answers: not answers['Consulta']
    }]

    answers = prompt(questions)
    if not answers['Consulta']:
        _rutas = answers['Rutas']
    else:
        _rutas = f._rutas

    rutas = tqdm(_rutas)
    if len(rutas) == 0:
        print('Han sido borradas las base intenta el dia de mañana')
    else:
        for i in rutas:
            f.DESCARGA(i)
            rutas.set_description("Descargando ruta: %s" % i)
            f.descomprimir(i)
            rutas.set_description("Descomprimiendo  ruta: %s" % i)
            f.procesarInfo(i)
            rutas.set_description("Obtenido info. ruta: %s" % i)
    print('Proceso Finalizado.')
Exemplo n.º 32
0
def ask_student(usernames):
    style = style_from_dict({
        Token.QuestionMark: '#959ee7 bold',
        Token.Selected: '#959ee7',
        Token.Pointer: '#959ee7 bold',
        Token.Answer: '#959ee7 bold',
    })
    questions = [
        {
            'type': 'list',
            'name': 'student',
            'message': 'Choose student',
            'choices': ['QUIT', 'LOG and QUIT', *usernames]
        }
    ]

    student = prompt(questions, style=style)

    if not student:
        return None

    return student['student']