mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 13:23:18 -07:00
Update vendored windows libs
This commit is contained in:
parent
f61c211655
commit
b1cefa94e5
226 changed files with 33472 additions and 11882 deletions
|
@ -1,34 +1,32 @@
|
|||
from __future__ import print_function, absolute_import, unicode_literals
|
||||
|
||||
import itertools
|
||||
|
||||
import six
|
||||
|
||||
class Menu(object):
|
||||
"""
|
||||
A simple command-line based menu
|
||||
"""
|
||||
def __init__(self, choices=None, formatter=str):
|
||||
self.choices = choices or list()
|
||||
self.formatter = formatter
|
||||
"""
|
||||
A simple command-line based menu
|
||||
"""
|
||||
|
||||
def get_choice(self, prompt="> "):
|
||||
n = len(self.choices)
|
||||
number_width = len(str(n)) + 1
|
||||
menu_fmt = '{number:{number_width}}) {choice}'
|
||||
formatted_choices = map(self.formatter, self.choices)
|
||||
for number, choice in zip(itertools.count(1), formatted_choices):
|
||||
print(menu_fmt.format(**locals()))
|
||||
print()
|
||||
try:
|
||||
answer = int(six.moves.input(prompt))
|
||||
result = self.choices[answer - 1]
|
||||
except ValueError:
|
||||
print('invalid selection')
|
||||
result = None
|
||||
except IndexError:
|
||||
print('invalid selection')
|
||||
result = None
|
||||
except KeyboardInterrupt:
|
||||
result = None
|
||||
return result
|
||||
def __init__(self, choices=None, formatter=str):
|
||||
self.choices = choices or list()
|
||||
self.formatter = formatter
|
||||
|
||||
def get_choice(self, prompt="> "):
|
||||
n = len(self.choices)
|
||||
number_width = len(str(n)) + 1
|
||||
menu_fmt = '{number:{number_width}}) {choice}'
|
||||
formatted_choices = map(self.formatter, self.choices)
|
||||
for number, choice in zip(itertools.count(1), formatted_choices):
|
||||
print(menu_fmt.format(**locals()))
|
||||
print()
|
||||
try:
|
||||
answer = int(input(prompt))
|
||||
result = self.choices[answer - 1]
|
||||
except ValueError:
|
||||
print('invalid selection')
|
||||
result = None
|
||||
except IndexError:
|
||||
print('invalid selection')
|
||||
result = None
|
||||
except KeyboardInterrupt:
|
||||
result = None
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue