1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

switch to click 7.0

This commit is contained in:
matejcik 2018-10-03 15:11:21 +02:00
parent 8618f44272
commit 2d7c74c535
4 changed files with 18 additions and 24 deletions

View File

@ -1,7 +1,7 @@
ecdsa>=0.9
mnemonic>=0.17
requests>=2.4.0
click>=6.2
click>=7,<8
pyblake2>=0.9.3
libusb1>=1.6.4
construct>=2.9

View File

@ -16,7 +16,7 @@ install_requires = [
"ecdsa>=0.9",
"mnemonic>=0.17",
"requests>=2.4.0",
"click>=6.2",
"click>=7,<8",
"pyblake2>=0.9.3",
"libusb1>=1.6.4",
"construct>=2.9",

View File

@ -89,12 +89,26 @@ CHOICE_OUTPUT_SCRIPT_TYPE = ChoiceType(
)
class UnderscoreAgnosticGroup(click.Group):
"""Command group that normalizes dashes and underscores.
Click 7.0 silently switched all underscore_commands to dash-commands.
This implementation of `click.Group` responds to underscore_commands by invoking
the respective dash-command.
"""
def get_command(self, ctx, cmd_name):
cmd = super().get_command(ctx, cmd_name)
if cmd is None:
cmd = super().get_command(ctx, cmd_name.replace("_", "-"))
return cmd
def enable_logging():
log.enable_debug_output()
log.OMITTED_MESSAGES.add(proto.Features)
@click.group(context_settings={"max_content_width": 400})
@click.command(cls=UnderscoreAgnosticGroup, context_settings={"max_content_width": 400})
@click.option(
"-p",
"--path",

View File

@ -101,30 +101,10 @@ def mnemonic_words(expand=False, language="english"):
return get_word
try:
# workaround for Click issue https://github.com/pallets/click/pull/1108
import msvcrt
def getchar():
while True:
key = msvcrt.getwch()
if key == "\x03":
raise KeyboardInterrupt
if key in (0x00, 0xE0):
# skip special keys: read the scancode and repeat
msvcrt.getwch()
continue
return key
except ImportError:
getchar = click.getchar
def matrix_words(type):
while True:
try:
ch = getchar()
ch = click.getchar()
except (KeyboardInterrupt, EOFError):
raise Cancelled from None