def choose_match(task): """Given an initial autotagging of items, go through an interactive dance with the user to ask for a choice of metadata. Returns an AlbumMatch object or SKIP. """ # Show what we're tagging. print_() print_( displayable_path(task.paths, u'\n') + u' ({0} items)'.format(len(task.items))) # Loop until we have a choice. candidates, rec = task.candidates, task.rec while True: # Ask for a choice from the user. choice = choose_candidate(candidates, False, rec, task.cur_artist, task.cur_album, itemcount=len(task.items)) # Choose which tags to use. if choice is importer.action.SKIP: # Pass selection to main control flow. return choice elif choice is importer.action.MANUAL: # Try again with manual search terms. search_artist, search_album = manual_search(False) _, _, candidates, rec = autotag.tag_album(task.items, search_artist, search_album) elif choice is importer.action.MANUAL_ID: # Try a manually-entered ID. search_id = manual_id(False) if search_id: _, _, candidates, rec = autotag.tag_album( task.items, search_ids=search_id.split()) else: # We have a candidate! Finish tagging. Here, choice is an # AlbumMatch object. assert isinstance(choice, autotag.AlbumMatch) return choice
def test_url_finds_id(self): self.io.addinput("http://musicbrainz.org/entity/%s?something" % AN_ID) out = commands.manual_id(False) self.assertEqual(out, AN_ID)
def test_non_id_returns_none(self): self.io.addinput("blah blah") out = commands.manual_id(False) self.assertEqual(out, None)
def test_id_accepted(self): self.io.addinput(AN_ID) out = commands.manual_id(False) self.assertEqual(out, AN_ID)