From 6f8a1aa40a7d79bf849a77a2cd12b0e54addddb0 Mon Sep 17 00:00:00 2001 From: Diego Moreda Date: Wed, 16 Dec 2015 19:26:39 +0100 Subject: [PATCH] Prompt event documentation and mbsubmit fixes * Fixes for documentation of the prompt event (missing reserved letter, typos). * Update sample mbsubmit plugin to conform to the new PromptChoice structure. --- beetsplug/mbsubmit.py | 6 ++---- docs/dev/plugins.rst | 11 ++++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/beetsplug/mbsubmit.py b/beetsplug/mbsubmit.py index 5e839b626..e86ca1ab7 100644 --- a/beetsplug/mbsubmit.py +++ b/beetsplug/mbsubmit.py @@ -40,10 +40,8 @@ class MBSubmitPlugin(BeetsPlugin): def before_choose_candidate_event(self, session, task): if not task.candidates or task.rec == Recommendation.none: - return [PromptChoice(self, 'PRINT', 'p', 'Print tracks', - self.print_tracks), - PromptChoice(self, 'PRINT_SKIP', 'k', - 'print tracks and sKip', + return [PromptChoice('p', 'Print tracks', self.print_tracks), + PromptChoice('k', 'print tracks and sKip', self.print_tracks_and_skip)] # Callbacks for choices. diff --git a/docs/dev/plugins.rst b/docs/dev/plugins.rst index 8fa4871bf..3b3ad80a2 100644 --- a/docs/dev/plugins.rst +++ b/docs/dev/plugins.rst @@ -547,6 +547,7 @@ a list of ``PromptChoices`` that represent the additional choices that your plugin shall expose to the user:: from beets.plugins import BeetsPlugin + from beets.ui.commands import PromptChoice class ExamplePlugin(BeetsPlugin): def __init__(self): @@ -555,14 +556,14 @@ plugin shall expose to the user:: self.before_choose_candidate_event) def before_choose_candidate_event(self, session, task): - return [PromptChoice(self, 'PRINT_FOO', 'p', 'Print foo', self.foo), - PromptChoice(self, 'DO_BAR', 'd', 'Do bar', self.bar)] + return [PromptChoice('p', 'Print foo', self.foo), + PromptChoice('d', 'Do bar', self.bar)] def foo(self, session, task): print('User has chosen "Print foo"!') def bar(self, session, task): - print('User has chosen "do Bar"!') + print('User has chosen "Do bar"!') The previous example modifies the standard prompt:: @@ -585,11 +586,11 @@ Please make sure that the short letter for each of the choices provided by the plugin is not already in use: the importer will raise an exception if two or more choices try to use the same short letter. As a reference, the following characters are used by the choices on the core importer prompt, and hence -should not be used: ``s``, ``u``, ``t``, ``g``, ``e``, ``i``, ``b``. +should not be used: ``a``, ``s``, ``u``, ``t``, ``g``, ``e``, ``i``, ``b``. Additionally, the callback function can optionally specify the next action to be performed by returning one of the values from ``importer.action``, which will be passed to the main loop upon the callback has been processed. Note that ``action.MANUAL`` and ``action.MANUAL_ID`` will have no effect even if -returned by the callback, due to the current arquitecture of the import +returned by the callback, due to the current architecture of the import process.