Skip to content

Commit 651146f

Browse files
committed
Merge branch 'jonathanslenders-prompt-toolkit-1.0.0'
* jonathanslenders-prompt-toolkit-1.0.0: Remove unused import Update failing test to use is_exiting attr Upgrade to prompt-toolkit 1.0.0
2 parents 8bfd6a9 + d275de1 commit 651146f

File tree

4 files changed

+28
-40
lines changed

4 files changed

+28
-40
lines changed

awsshell/app.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from prompt_toolkit.filters import Always
1616
from prompt_toolkit.interface import CommandLineInterface, Application
1717
from prompt_toolkit.interface import AbortAction, AcceptAction
18-
from prompt_toolkit.utils import Callback
1918
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
2019
from prompt_toolkit.history import InMemoryHistory, FileHistory
2120

@@ -279,7 +278,7 @@ def cli(self):
279278
def run(self):
280279
while True:
281280
try:
282-
document = self.cli.run()
281+
document = self.cli.run(reset_current_buffer=True)
283282
text = document.text
284283
except InputInterrupt:
285284
pass
@@ -423,7 +422,7 @@ def create_application(self, completer, history,
423422
buffer=self.create_buffer(completer, history),
424423
on_abort=AbortAction.RETRY,
425424
on_exit=AbortAction.RAISE_EXCEPTION,
426-
on_input_timeout=Callback(self.on_input_timeout),
425+
on_input_timeout=self.on_input_timeout,
427426
key_bindings_registry=self.key_manager.manager.registry,
428427
)
429428

awsshell/style.py

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
# ANY KIND, either express or implied. See the License for the specific
1212
# language governing permissions and limitations under the License.
1313
from pygments.token import Token
14-
from pygments.style import Style
1514
from pygments.util import ClassNotFound
1615
from pygments.styles import get_style_by_name
17-
from prompt_toolkit.styles import default_style_extensions
16+
from prompt_toolkit.styles import default_style_extensions, style_from_dict
1817

1918

2019
class StyleFactory(object):
@@ -43,32 +42,26 @@ def style_factory(self, style_name):
4342
except ClassNotFound:
4443
style = get_style_by_name('vim')
4544

46-
class CliStyle(Style):
47-
"""Provides styles for the autocomplete menu and the toolbar.
45+
# Create a style dictionary.
46+
styles = {}
47+
styles.update(style.styles)
48+
styles.update(default_style_extensions)
49+
t = Token
50+
styles.update({
51+
t.Menu.Completions.Completion.Current: 'bg:#00aaaa #000000',
52+
t.Menu.Completions.Completion: 'bg:#008888 #ffffff',
53+
t.Menu.Completions.Meta.Current: 'bg:#00aaaa #000000',
54+
t.Menu.Completions.Meta: 'bg:#00aaaa #ffffff',
55+
t.Scrollbar.Button: 'bg:#003333',
56+
t.Scrollbar: 'bg:#00aaaa',
57+
t.Toolbar: 'bg:#222222 #cccccc',
58+
t.Toolbar.Off: 'bg:#222222 #696969',
59+
t.Toolbar.On: 'bg:#222222 #ffffff',
60+
t.Toolbar.Search: 'noinherit bold',
61+
t.Toolbar.Search.Text: 'nobold',
62+
t.Toolbar.System: 'noinherit bold',
63+
t.Toolbar.Arg: 'noinherit bold',
64+
t.Toolbar.Arg.Text: 'nobold'
65+
})
4866

49-
:type styles: dict
50-
:param styles: Contains pygments style info.
51-
"""
52-
53-
styles = {}
54-
styles.update(style.styles)
55-
styles.update(default_style_extensions)
56-
t = Token
57-
styles.update({
58-
t.Menu.Completions.Completion.Current: 'bg:#00aaaa #000000',
59-
t.Menu.Completions.Completion: 'bg:#008888 #ffffff',
60-
t.Menu.Completions.Meta.Current: 'bg:#00aaaa #000000',
61-
t.Menu.Completions.Meta: 'bg:#00aaaa #ffffff',
62-
t.Menu.Completions.ProgressButton: 'bg:#003333',
63-
t.Menu.Completions.ProgressBar: 'bg:#00aaaa',
64-
t.Toolbar: 'bg:#222222 #cccccc',
65-
t.Toolbar.Off: 'bg:#222222 #696969',
66-
t.Toolbar.On: 'bg:#222222 #ffffff',
67-
t.Toolbar.Search: 'noinherit bold',
68-
t.Toolbar.Search.Text: 'nobold',
69-
t.Toolbar.System: 'noinherit bold',
70-
t.Toolbar.Arg: 'noinherit bold',
71-
t.Toolbar.Arg.Text: 'nobold'
72-
})
73-
74-
return CliStyle
67+
return style_from_dict(styles)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
requires = [
99
'awscli>=1.8.9,<2.0.0',
10-
'prompt-toolkit==0.52',
10+
'prompt-toolkit>=1.0.0,<1.1.0',
1111
'boto3>=1.2.1,<2.0.0',
1212
'configobj>=5.0.6,<6.0.0',
1313
'Pygments>=2.1.3,<3.0.0',

tests/integration/test_keys.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,5 @@ def test_F5(self):
5252
assert show_help != self.aws_shell.show_help
5353

5454
def test_F10(self):
55-
# Exiting from the test in this mock test environment will throw:
56-
# IOError: [Errno 25] Inappropriate ioctl for device
57-
# In a non-mock test environment it would through a EOFError.
58-
# TODO: Probably better to mock the call to event.cli.set_exit().
59-
with self.assertRaises(IOError) as e:
60-
self.processor.feed_key(KeyPress(Keys.F10, ''))
55+
self.processor.feed_key(KeyPress(Keys.F10, ''))
56+
assert self.aws_shell.cli.is_exiting

0 commit comments

Comments
 (0)