From 07dbe042f510a7002fbe5040e6c9ed227437e943 Mon Sep 17 00:00:00 2001 From: Thomas Scholtes Date: Sun, 20 Apr 2014 18:04:45 +0200 Subject: [PATCH] Move set_candidate logic --- beets/importer.py | 34 ++++++++-------------------------- test/test_ui.py | 26 -------------------------- 2 files changed, 8 insertions(+), 52 deletions(-) diff --git a/beets/importer.py b/beets/importer.py index a290faad0..6d2d9ed2b 100644 --- a/beets/importer.py +++ b/beets/importer.py @@ -283,15 +283,6 @@ class ImportTask(object): self.remove_duplicates = False self.is_album = True - def set_candidates(self, cur_artist, cur_album, candidates, rec): - """Sets the candidates for this album matched by the - `autotag.tag_album` method. - """ - self.cur_artist = cur_artist - self.cur_album = cur_album - self.candidates = candidates - self.rec = rec - def set_null_candidates(self): """Set the candidates to indicate no album match was found. """ @@ -300,9 +291,6 @@ class ImportTask(object): self.candidates = None self.rec = None - def set_item_candidates(self, candidates, rec): - raise NotImplementedError - def set_choice(self, choice): """Given an AlbumMatch or TrackMatch object or an action constant, indicates that an action has been selected for this task. @@ -439,7 +427,11 @@ class ImportTask(object): def lookup_candidates(self): """Retrieve and store candidates for this album. """ - self.set_candidates(*autotag.tag_album(self.items)) + artist, album, candidates, recommendation = autotag.tag_album(self.items) + self.cur_artist = artist + self.cur_album = album + self.candidates = candidates + self.rec = recommendation def find_duplicates(self, lib): """Return a list of albums from `lib` with the same artist and @@ -622,15 +614,6 @@ class SingletonImportTask(ImportTask): # TODO we should also save history for singletons pass - def set_item_candidates(self, candidates, rec): - """Set the match for a single-item task.""" - assert self.item is not None - self.candidates = candidates - self.rec = rec - - def set_candidates(self, cur_artist, cur_album, candidates, rec): - raise NotImplementedError - def apply_metadata(self): autotag.apply_item_metadata(self.item, self.match.info) @@ -643,7 +626,9 @@ class SingletonImportTask(ImportTask): plugins.send('item_imported', lib=session.lib, item=item) def lookup_candidates(self): - self.set_item_candidates(*autotag.tag_item(self.item)) + candidates, recommendation = autotag.tag_item(self.item) + self.candidates = candidates + self.rec = recommendation def find_duplicates(self, lib): """Return a list of items from `lib` that have the same artist @@ -718,9 +703,6 @@ class SentinelImportTask(ImportTask): def set_choice(self, choice): raise NotImplementedError - def set_candidates(self, cur_artist, cur_album, candidates, rec): - raise NotImplementedError - def cleanup(self, session): pass diff --git a/test/test_ui.py b/test/test_ui.py index 54cbb533f..d28587c0a 100644 --- a/test/test_ui.py +++ b/test/test_ui.py @@ -473,32 +473,6 @@ class PrintTest(_common.TestCase): del os.environ['LC_CTYPE'] -class AutotagTest(_common.TestCase): - def setUp(self): - super(AutotagTest, self).setUp() - self.io.install() - - def _no_candidates_test(self, result): - task = importer.ImportTask( - 'toppath', - 'path', - [_common.item()], - ) - task.set_candidates('artist', 'album', [], autotag.Recommendation.none) - session = _common.import_session(cli=True) - res = session.choose_match(task) - self.assertEqual(res, result) - self.assertTrue('No match' in self.io.getoutput()) - - def test_choose_match_with_no_candidates_skip(self): - self.io.addinput('s') - self._no_candidates_test(importer.action.SKIP) - - def test_choose_match_with_no_candidates_asis(self): - self.io.addinput('u') - self._no_candidates_test(importer.action.ASIS) - - class ImportTest(_common.TestCase): def test_quiet_timid_disallowed(self): config['import']['quiet'] = True