From ffcaf3384548ab95275c5489bb8dbf1631dd0687 Mon Sep 17 00:00:00 2001 From: xarph Date: Tue, 18 Apr 2017 15:30:24 -0700 Subject: [PATCH 1/2] add -f argument to play command --- beetsplug/play.py | 7 ++++++- docs/changelog.rst | 3 +++ docs/plugins/play.rst | 3 +++ test/test_play.py | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/beetsplug/play.py b/beetsplug/play.py index 9e912dbce..409e0c4ab 100644 --- a/beetsplug/play.py +++ b/beetsplug/play.py @@ -81,6 +81,11 @@ class PlayPlugin(BeetsPlugin): action='store', help=u'add additional arguments to the command', ) + play_command.parser.add_option( + u'-f', u'--force', + action="store_true", + help=u'disable the warning threshold', + ) play_command.func = self._play_command return [play_command] @@ -125,7 +130,7 @@ class PlayPlugin(BeetsPlugin): # Check if the selection exceeds configured threshold. If True, # cancel, otherwise proceed with play command. - if not self._exceeds_threshold(selection, command_str, open_args, + if opts.force or not self._exceeds_threshold(selection, command_str, open_args, item_type): play(command_str, selection, paths, open_args, self._log, item_type) diff --git a/docs/changelog.rst b/docs/changelog.rst index ddb6ec603..cd539d0cf 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -49,6 +49,9 @@ New features: :bug:`2366` :bug:`2495` * Importing a release with multiple release events now selects the event based on your :ref:`preferred` countries. :bug:`2501` +* :doc:`/plugins/play`: A new ``-f`` or ``--force`` parameter lets you skip + the warning message if you enqueue more items than the warning threshold + usually allows. Fixes: diff --git a/docs/plugins/play.rst b/docs/plugins/play.rst index 9b9110bde..71baa0388 100644 --- a/docs/plugins/play.rst +++ b/docs/plugins/play.rst @@ -95,6 +95,9 @@ example:: indicates that you need to insert extra arguments before specifying the playlist. +The ``--force`` (or ``-f``) flag to the ``play`` command will skip the warning +message if you choose to play more items than the **warning_threshold** value. + Note on the Leakage of the Generated Playlists ---------------------------------------------- diff --git a/test/test_play.py b/test/test_play.py index 86fef99a9..685632b40 100644 --- a/test/test_play.py +++ b/test/test_play.py @@ -115,6 +115,20 @@ class PlayPluginTest(unittest.TestCase, TestHelper): open_mock.assert_not_called() + def test_force_warning_threshold_bypass(self, open_mock): + self.config['play']['warning_threshold'] = 1 + self.other_item = self.add_item(title='another NiceTitle') + + expected_playlist = u'{0}\n{1}'.format( + self.item.path.decode('utf-8'), + self.other_item.path.decode('utf-8')) + + with control_stdin("a"): + self.run_and_assert( + open_mock, + [u'-f', u'NiceTitle'], + expected_playlist=expected_playlist) + def test_command_failed(self, open_mock): open_mock.side_effect = OSError(u"some reason") From 02aa6191c1af4fd39a1d5f31de6ef27ade3aa9f6 Mon Sep 17 00:00:00 2001 From: xarph Date: Wed, 19 Apr 2017 10:51:44 -0700 Subject: [PATCH 2/2] rename --force to --yes in play plugin fix some pep8 goo --- beetsplug/play.py | 8 ++++---- docs/changelog.rst | 2 +- docs/plugins/play.rst | 5 +++-- test/test_play.py | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/beetsplug/play.py b/beetsplug/play.py index 409e0c4ab..8477acbfc 100644 --- a/beetsplug/play.py +++ b/beetsplug/play.py @@ -82,9 +82,9 @@ class PlayPlugin(BeetsPlugin): help=u'add additional arguments to the command', ) play_command.parser.add_option( - u'-f', u'--force', + u'-y', u'--yes', action="store_true", - help=u'disable the warning threshold', + help=u'skip the warning threshold', ) play_command.func = self._play_command return [play_command] @@ -130,8 +130,8 @@ class PlayPlugin(BeetsPlugin): # Check if the selection exceeds configured threshold. If True, # cancel, otherwise proceed with play command. - if opts.force or not self._exceeds_threshold(selection, command_str, open_args, - item_type): + if opts.yes or not self._exceeds_threshold( + selection, command_str, open_args, item_type): play(command_str, selection, paths, open_args, self._log, item_type) diff --git a/docs/changelog.rst b/docs/changelog.rst index cd539d0cf..7fa0dbcbb 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -49,7 +49,7 @@ New features: :bug:`2366` :bug:`2495` * Importing a release with multiple release events now selects the event based on your :ref:`preferred` countries. :bug:`2501` -* :doc:`/plugins/play`: A new ``-f`` or ``--force`` parameter lets you skip +* :doc:`/plugins/play`: A new ``-y`` or ``--yes`` parameter lets you skip the warning message if you enqueue more items than the warning threshold usually allows. diff --git a/docs/plugins/play.rst b/docs/plugins/play.rst index 71baa0388..3a08a4239 100644 --- a/docs/plugins/play.rst +++ b/docs/plugins/play.rst @@ -95,8 +95,9 @@ example:: indicates that you need to insert extra arguments before specifying the playlist. -The ``--force`` (or ``-f``) flag to the ``play`` command will skip the warning -message if you choose to play more items than the **warning_threshold** value. +The ``--yes`` (or ``-y``) flag to the ``play`` command will skip the warning +message if you choose to play more items than the **warning_threshold** +value usually allows. Note on the Leakage of the Generated Playlists ---------------------------------------------- diff --git a/test/test_play.py b/test/test_play.py index 685632b40..9721143cc 100644 --- a/test/test_play.py +++ b/test/test_play.py @@ -115,7 +115,7 @@ class PlayPluginTest(unittest.TestCase, TestHelper): open_mock.assert_not_called() - def test_force_warning_threshold_bypass(self, open_mock): + def test_skip_warning_threshold_bypass(self, open_mock): self.config['play']['warning_threshold'] = 1 self.other_item = self.add_item(title='another NiceTitle') @@ -126,7 +126,7 @@ class PlayPluginTest(unittest.TestCase, TestHelper): with control_stdin("a"): self.run_and_assert( open_mock, - [u'-f', u'NiceTitle'], + [u'-y', u'NiceTitle'], expected_playlist=expected_playlist) def test_command_failed(self, open_mock):