Пример #1
0
 def test_manual_search_gets_unicode(self):
     # The input here uses "native strings": bytes on Python 2, Unicode on
     # Python 3.
     self.io.addinput('foö')
     self.io.addinput('bár')
     artist, album = commands.manual_search(False)
     self.assertEqual(artist, u'foö')
     self.assertEqual(album, u'bár')
Пример #2
0
 def test_manual_search_gets_unicode(self):
     # The input here uses "native strings": bytes on Python 2, Unicode on
     # Python 3.
     self.io.addinput('foö')
     self.io.addinput('bár')
     artist, album = commands.manual_search(False)
     self.assertEqual(artist, u'foö')
     self.assertEqual(album, u'bár')
Пример #3
0
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
Пример #4
0
 def test_manual_search_gets_unicode(self):
     self.io.addinput('\xc3\x82me')
     self.io.addinput('\xc3\x82me')
     artist, album = commands.manual_search(False)
     self.assertEqual(artist, u'\xc2me')
     self.assertEqual(album, u'\xc2me')
Пример #5
0
 def test_manual_search_gets_unicode(self):
     self.io.addinput(b'\xc3\x82me')
     self.io.addinput(b'\xc3\x82me')
     artist, album = commands.manual_search(False)
     self.assertEqual(artist, u'\xc2me')
     self.assertEqual(album, u'\xc2me')