From f388427e77974892696c62812478288a4690f5a6 Mon Sep 17 00:00:00 2001 From: John Victor Sampaio Date: Sat, 8 Feb 2020 15:28:49 -0300 Subject: [PATCH] Switch PyInquirer with questionary --- CHANGELOG.md | 8 ++++++ nyaacli/colors.py | 23 +++++++++-------- nyaacli/nyaa_search.py | 12 ++------- poetry.lock | 57 ++++++++++++++++-------------------------- pyproject.toml | 2 +- 5 files changed, 46 insertions(+), 56 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88d4bcf..fb2152f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/nyaacli/colors.py b/nyaacli/colors.py index 2b0406f..f8a4278 100644 --- a/nyaacli/colors.py +++ b/nyaacli/colors.py @@ -1,4 +1,4 @@ -from PyInquirer import Token, style_from_dict +from prompt_toolkit import styles from colorama import init, Fore, Style init() @@ -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') +]) diff --git a/nyaacli/nyaa_search.py b/nyaacli/nyaa_search.py index 6fdd52d..8d4681e 100644 --- a/nyaacli/nyaa_search.py +++ b/nyaacli/nyaa_search.py @@ -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 @@ -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: diff --git a/poetry.lock b/poetry.lock index 13aa843..cd0ae66 100644 --- a/poetry.lock +++ b/poetry.lock @@ -118,11 +118,10 @@ category = "main" description = "Library for building powerful interactive command lines in Python" name = "prompt-toolkit" optional = false -python-versions = "*" -version = "1.0.18" +python-versions = ">=3.6" +version = "3.0.3" [package.dependencies] -six = ">=1.9.0" wcwidth = "*" [[package]] @@ -143,38 +142,28 @@ version = "2.1.1" [[package]] category = "main" -description = "Pygments is a syntax highlighting package written in Python." -name = "pygments" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -version = "2.5.2" - -[[package]] -category = "main" -description = "A Python module for collection of common interactive command line user interfaces, based on Inquirer.js" -name = "PyInquirer" +description = "Extensions to the standard Python datetime module" +name = "python-dateutil" optional = false -python-versions = "*" -version = "1.0.3" +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +version = "2.8.1" [package.dependencies] -Pygments = ">=2.2.0" -prompt_toolkit = "1.0.18" +six = ">=1.5" -[package.source] -reference = "f98f8e6b4829c0ccf2cd88d7a3693f1a5d0e2d47" -type = "git" -url = "https://github.com/johnvictorfs/PyInquirer.git" [[package]] category = "main" -description = "Extensions to the standard Python datetime module" -name = "python-dateutil" +description = "Python library to build pretty command line user prompts ⭐️" +name = "questionary" optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" -version = "2.8.1" +python-versions = "*" +version = "1.5.1" [package.dependencies] -six = ">=1.5" +prompt-toolkit = ">=2.0,<4.0" + +[package.extras] +test = ["pytest (>=4.0,<5.0)", "pytest-pycodestyle (>=1.3,<2.0)", "pytest-cov (>=2.6,<3.0)", "coveralls (>=1.3,<2.0)"] [[package]] category = "main" @@ -225,7 +214,7 @@ python-versions = "*" version = "0.1.8" [metadata] -content-hash = "38d3c042dee48ad44ce1e1568cfeb5a9c972b097303c489c8ded88d23508b1fd" +content-hash = "c76750b09e5ef10a6bcd5d2370adc5738315b900f87979c308588723e92bca0f" python-versions = "^3.7" [metadata.files] @@ -284,9 +273,8 @@ mypy-extensions = [ {file = "mypy_extensions-0.4.3.tar.gz", hash = "sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"}, ] prompt-toolkit = [ - {file = "prompt_toolkit-1.0.18-py2-none-any.whl", hash = "sha256:f7eec66105baf40eda9ab026cd8b2e251337eea8d111196695d82e0c5f0af852"}, - {file = "prompt_toolkit-1.0.18-py3-none-any.whl", hash = "sha256:37925b37a4af1f6448c76b7606e0285f79f434ad246dda007a27411cca730c6d"}, - {file = "prompt_toolkit-1.0.18.tar.gz", hash = "sha256:dd4fca02c8069497ad931a2d09914c6b0d1b50151ce876bc15bde4c747090126"}, + {file = "prompt_toolkit-3.0.3-py3-none-any.whl", hash = "sha256:c93e53af97f630f12f5f62a3274e79527936ed466f038953dfa379d4941f651a"}, + {file = "prompt_toolkit-3.0.3.tar.gz", hash = "sha256:a402e9bf468b63314e37460b68ba68243d55b2f8c4d0192f85a019af3945050e"}, ] pycodestyle = [ {file = "pycodestyle-2.5.0-py2.py3-none-any.whl", hash = "sha256:95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56"}, @@ -296,15 +284,14 @@ pyflakes = [ {file = "pyflakes-2.1.1-py2.py3-none-any.whl", hash = "sha256:17dbeb2e3f4d772725c777fabc446d5634d1038f234e77343108ce445ea69ce0"}, {file = "pyflakes-2.1.1.tar.gz", hash = "sha256:d976835886f8c5b31d47970ed689944a0262b5f3afa00a5a7b4dc81e5449f8a2"}, ] -pygments = [ - {file = "Pygments-2.5.2-py2.py3-none-any.whl", hash = "sha256:2a3fe295e54a20164a9df49c75fa58526d3be48e14aceba6d6b1e8ac0bfd6f1b"}, - {file = "Pygments-2.5.2.tar.gz", hash = "sha256:98c8aa5a9f778fcd1026a17361ddaf7330d1b7c62ae97c3bb0ae73e0b9b6b0fe"}, -] -PyInquirer = [] python-dateutil = [ {file = "python-dateutil-2.8.1.tar.gz", hash = "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c"}, {file = "python_dateutil-2.8.1-py2.py3-none-any.whl", hash = "sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a"}, ] +questionary = [ + {file = "questionary-1.5.1-py3-none-any.whl", hash = "sha256:5314bfb746321997a9dc457e5e0a533e577a661347f3a89c63277c6746e9a8b9"}, + {file = "questionary-1.5.1.tar.gz", hash = "sha256:f199d4a780183679725f10a209b68be27f07cfd2852d6d7ea9e4a31fb45fb0c0"}, +] rebulk = [ {file = "rebulk-2.0.0.tar.gz", hash = "sha256:1b0d526859ef3e8647f37c606d7ae7c32259e370b3f1519e4219a3ba72740aec"}, ] diff --git a/pyproject.toml b/pyproject.toml index 772779b..f6fb3a4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"