Skip to content

Commit

Permalink
Switch PyInquirer with questionary
Browse files Browse the repository at this point in the history
  • Loading branch information
johnvictorfs committed Feb 8, 2020
1 parent 4346468 commit f388427
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 56 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

---

## 0.1.6

- Update PyInquirer to forked version to fix issue with searching for Anime with broken 'regex' package [`(4346468)`](https://github.com/johnvictorfs/nyaa-cli/commit/434646855683b69f5def77b9f03bc75819aa9d89) (Closes Issue #20)

- Switch PyInquirer entirely with [questionary](https://github.com/tmbo/questionary)

---

## 0.1.5

- Fix issue where selecting no Episodes when searching barely got any selections [`(697978b)`](https://github.com/johnvictorfs/nyaa-cli/commit/697978bd40d9524f74711d97bee06a8387d99411)
Expand Down
23 changes: 13 additions & 10 deletions nyaacli/colors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from PyInquirer import Token, style_from_dict
from prompt_toolkit import styles
from colorama import init, Fore, Style

init()
Expand All @@ -20,12 +20,15 @@ def blue(text: str) -> str:
return Fore.BLUE + text + Style.RESET_ALL


prompt_style = style_from_dict({
Token.Separator: '#6C6C6C',
Token.QuestionMark: '#5F819D',
Token.Selected: '#48b5b5 bold',
Token.Pointer: '#48b5b5 bold',
Token.Instruction: '#77a371',
Token.Answer: '#48b5b5 bold',
Token.Question: '#289c64 bold',
})
prompt_style = styles.Style([
('qmark', 'fg:#5F819D bold'),
('question', 'fg:#289c64 bold'),
('answer', 'fg:#48b5b5 bold'),
('pointer', 'fg:#48b5b5 bold'),
('highlighted', 'fg:#07d1e8'),
('selected', 'fg:#48b5b5 bold'),
('separator', 'fg:#6C6C6C'),
('instruction', 'fg:#77a371'),
('text', ''),
('disabled', 'fg:#858585 italic')
])
12 changes: 2 additions & 10 deletions nyaacli/nyaa_search.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from PyInquirer import prompt
from questionary import prompt
from guessit import guessit

from nyaacli.colors import red, green, prompt_style
from nyaacli.colors import red, yellow, green, prompt_style

from urllib import request
from typing import Optional, List, Tuple
Expand Down Expand Up @@ -141,14 +141,6 @@ def search_torrent(search: str, episode: Optional[int] = None, dub: bool = False

if entry.seeders:
seeders = f'{entry.seeders} Seeders'

# Colors on options are not working very well with PyInquirer
# if int(entry.seeders) > 40:
# entry_title += f" - {green(seeders)}"
# elif 40 > int(entry.seeders) > 20:
# entry_title += f" - {yellow(seeders)}"
# else:
# entry_title += f" - {red(seeders)}"
entry_title += f' - {seeders}'

if entry.size:
Expand Down
57 changes: 22 additions & 35 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ guessit = "^3.0"
click = "^7.0"
colorama = "^0.4.1"
dataclasses = { version = "^0.7", python = "~3.6" }
PyInquirer = { git = "https://github.com/johnvictorfs/PyInquirer.git", branch = "master" }
questionary = "^1.5.1"

[tool.poetry.dev-dependencies]
autopep8 = "^1.4"
Expand Down

0 comments on commit f388427

Please sign in to comment.