Exemplo n.º 1
0
def get_multiple(
    question: str, confirmation: str, value_type: type
) -> List[Union[str, int]]:
    """Give possibility to user to fill multiple value.

    Parameters
    ----------
    question:str
        First question.
    confirmation:str
        Asking text if user want to add another.
    value_type:type
        The type of values inside the list.

    Returns
    -------
    List[Union[str, int]]
        List containing user filled values.
    """
    prompt: Union[IntPrompt, Prompt] = (
        IntPrompt() if value_type is int else Prompt()
    )

    user_input = prompt.ask(question, console=console)

    if not user_input:
        return []

    values = [user_input]

    while (
        Prompt.ask(
            confirmation, choices=["y", "n"], default="n", console=console
        )
        != "n"
    ):
        new = prompt.ask("Other")

        if new not in values:
            values.append(new)
        else:
            console.print(
                f"[prompt.invalid]"
                f"ERROR: `{new}` is already present, [i]ignored[/i]"
            )

    return values
Exemplo n.º 2
0
from rich import print
from rich.progress import track
from time import sleep
from rich.console import Console
from rich.table import Table
from rich.prompt import Prompt

cpf = 0
conf = 0
opc = 0

prompt = Prompt()
console = Console()
table = Table(title="DJHOW TELECOM\n")

table.add_column("Plano", style="bold green")
table.add_column("Velocidade", style="bold blue")
table.add_column("Valor", style="bold yellow")

table.add_row("Básico", "100 Mbps", "R$ 50,00")
table.add_row("Premium", "250 Mbps", "R$ 80,00")
table.add_row("Master", "1 Gbps", "R$ 150,00")

while conf == 0:
    cpf = int(input("Informe o número do seu CPF: "))
    conf = prompt.ask(
        f'CPF informado: [on black]{cpf}[/]. Correto (1-sim/0-não)?')

for i in track(range(10), "Aguarde enquanto buscamos seu CPF no sistema..."):
    sleep(1)
print(" ")
Exemplo n.º 3
0
def get_extra(question: str, value_type: type) -> Union[str, int]:
    prompt: Union[IntPrompt, Prompt] = (
        IntPrompt() if value_type is int else Prompt()
    )
    return prompt.ask(question, console=console)
Exemplo n.º 4
0
 def prompt_search():
     return Prompt("Search")