-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from staticdev/feature/new-interface-prompt-too…
…lkit New interface prompt toolkit
- Loading branch information
Showing
11 changed files
with
82 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
/docs/_build/ | ||
/src/*.egg-info/ | ||
__pycache__/ | ||
*.xls | ||
|
||
# Pycharm | ||
.idea/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,36 @@ | ||
"""Prompt module.""" | ||
from __future__ import annotations | ||
|
||
from typing import Any | ||
import prompt_toolkit.shortcuts as shortcuts | ||
|
||
import inquirer | ||
|
||
TITLE = "IRPF Investidor" | ||
|
||
def select_trades(trades: list[tuple[str, int]]) -> Any: | ||
|
||
def select_trades(trades: list[tuple[int, str]]) -> list[int]: | ||
"""Checkbox selection of auction trades. | ||
Args: | ||
trades (list[tuple[str, int]]): list of all trades and indexes. | ||
trades: list of all trades and indexes. | ||
Returns: | ||
Any: list of indexes of selected auction trades. | ||
list of string indexes of selected auction trades. | ||
""" | ||
text = ( | ||
"Informe as operações realizadas em horário de leilão para cálculo dos " | ||
"emolumentos.\nEssa informação é obtida através de sua corretora." | ||
) | ||
while True: | ||
selection = inquirer.prompt( | ||
[ | ||
inquirer.Checkbox( | ||
"trades", | ||
message=( | ||
"Quais operações foram realizadas em horário de leilão? " | ||
"(Selecione apertando espaço e ao terminar aperte enter)" | ||
), | ||
choices=trades, | ||
) | ||
] | ||
)["trades"] | ||
if len(selection) == 0: | ||
answer = inquirer.prompt( | ||
[ | ||
inquirer.List( | ||
"", | ||
message="Nenhuma operação selecionada.\nIsso está correto?", | ||
choices=["Sim", "Não"], | ||
) | ||
] | ||
)[""] | ||
if answer == "Sim": | ||
operations: list[int] = shortcuts.checkboxlist_dialog( | ||
title=TITLE, | ||
text=text, | ||
values=trades, # type: ignore | ||
).run() | ||
if not operations or len(operations) == 0: | ||
confirmed = shortcuts.yes_no_dialog( | ||
title=TITLE, text="Nenhuma operação selecionada.\nIsso está correto?" | ||
).run() | ||
if confirmed: | ||
return [] | ||
else: | ||
return selection | ||
return operations |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.