当前位置: 首页>>代码示例>>Python>>正文


Python library.SongLibrary类代码示例

本文整理汇总了Python中quodlibet.library.SongLibrary的典型用法代码示例。如果您正苦于以下问题:Python SongLibrary类的具体用法?Python SongLibrary怎么用?Python SongLibrary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SongLibrary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

 def setUp(self):
     config.init()
     self.h = SongsMenuPluginHandler()
     library = SongLibrary()
     library.librarian = SongLibrarian()
     self.lib = library
     self.parent = Gtk.Window()
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:7,代码来源:test_songsmenu.py

示例2: TSongTracker

class TSongTracker(TestCase):
    def setUp(self):
        config.init()
        self.p = NullPlayer()
        self.w = SongLibrary()
        self.s1 = AudioFile(
            {"~#playcount": 0, "~#skipcount": 0, "~#lastplayed": 10,
             "~filename": "foo", "~#length": 1.5})
        self.s2 = AudioFile(
            {"~#playcount": 0, "~#skipcount": 0, "~#lastplayed": 10,
             "~filename": "foo", "~#length": 1.5})
        self.cm = SongTracker(self.w, self.p, self)
        self.current = None

    def do(self):
        while Gtk.events_pending():
            Gtk.main_iteration()

    def test_destroy(self):
        self.cm.destroy()

    def test_play(self):
        import time
        # Allow at least 2 second to elapse to simulate playing
        self.p.song = self.s1
        self.p.paused = False
        time.sleep(2)
        self.do()
        self.p.emit('song-ended', self.s1, False)
        self.do()
        t = time.time()
        self.assertEquals(self.s1["~#playcount"], 1)
        self.assertEquals(self.s1["~#skipcount"], 0)
        self.failUnless(t - self.s1["~#lastplayed"] <= 1)

    def test_skip(self):
        self.p.emit('song-ended', self.s1, True)
        self.do()
        self.assertEquals(self.s1["~#playcount"], 0)
        self.assertEquals(self.s1["~#skipcount"], 1)
        self.failUnless(self.s1["~#lastplayed"], 10)

    def test_error(self):
        self.current = self.p.song = self.s1
        self.p._error('Test error')
        self.do()
        self.assertEquals(self.s1["~#playcount"], 0)
        self.assertEquals(self.s1["~#skipcount"], 0)
        self.failUnless(self.s1["~#lastplayed"], 10)

    def test_restart(self):
        self.current = self.s1
        self.p.emit('song-ended', self.s1, True)
        self.do()
        self.assertEquals(self.s1["~#playcount"], 0)
        self.assertEquals(self.s1["~#skipcount"], 0)

    def tearDown(self):
        self.w.destroy()
        config.quit()
开发者ID:vrasidas,项目名称:quodlibet,代码行数:60,代码来源:test_qltk_tracker.py

示例3: TInformation

class TInformation(TestCase):
    def setUp(self):
        quodlibet.config.init()
        self.library = SongLibrary()

    def test_none(self):
        Information(self.library, []).destroy()

    def test_one(self):
        f = AF({"~filename": "/dev/null"})
        Information(self.library, [f]).destroy()

    def test_two(self):
        f = AF({"~filename": "/dev/null"})
        f2 = AF({"~filename": "/dev/null2"})
        Information(self.library, [f, f2]).destroy()

    def test_album(self):
        f = AF({"~filename": "/dev/null", "album": "woo"})
        f2 = AF({"~filename": "/dev/null2", "album": "woo"})
        Information(self.library, [f, f2]).destroy()

    def test_artist(self):
        f = AF({"~filename": "/dev/null", "artist": "woo"})
        f2 = AF({"~filename": "/dev/null2", "artist": "woo"})
        Information(self.library, [f, f2]).destroy()

    def tearDown(self):
        self.library.destroy()
        quodlibet.config.quit()
开发者ID:silkecho,项目名称:glowing-silk,代码行数:30,代码来源:test_qltk_information.py

示例4: TRatingsMenuItem

class TRatingsMenuItem(TestCase):

    def setUp(self):
        config.RATINGS = config.HardCodedRatingsPrefs()
        self.failUnlessEqual(config.RATINGS.number, NUM_RATINGS)
        self.library = SongLibrary()
        self.library.librarian = SongLibrarian()
        self.af = AudioFile({"~filename": fsnative(u"/foo"), "~#rating": 1.0})
        self.af.sanitize()
        self.rmi = RatingsMenuItem([self.af], self.library)

    def tearDown(self):
        self.rmi.destroy()
        self.library.destroy()
        self.library.librarian.destroy()

    def test_menuitem_children(self):
        children = [mi for mi in self.rmi.get_submenu().get_children()
                    if isinstance(mi, Gtk.CheckMenuItem)]
        self.failUnlessEqual(len(children), NUM_RATINGS + 1)
        highest = children[-1]
        self.failUnlessEqual(highest.get_active(), True)
        self.failUnlessEqual(children[1].get_active(), False)

    def test_set_remove_rating(self):
        self.rmi.set_rating(0.5, [self.af], self.library)
        self.failUnless(self.af.has_rating)
        self.failUnlessEqual(self.af('~#rating'), 0.5)
        self.rmi.remove_rating([self.af], self.library)
        self.failIf(self.af.has_rating)
开发者ID:hongquan,项目名称:quodlibet,代码行数:30,代码来源:test_qltk_ratingsmenu.py

示例5: test_menuitem

 def test_menuitem(self):
     library = SongLibrary()
     library.librarian = SongLibrarian()
     a = AudioFile({"~filename": fsnative(u"/foo")})
     a.sanitize()
     x = RatingsMenuItem([a], library)
     x.set_rating(0, [a], library)
     x.destroy()
     library.destroy()
     library.librarian.destroy()
开发者ID:bossjones,项目名称:quodlibet,代码行数:10,代码来源:test_qltk_ratingsmenu.py

示例6: setUp

 def setUp(self):
     config.init()
     config.set("browsers", "panes", "artist")
     library = SongLibrary()
     library.librarian = SongLibrarian()
     PanedBrowser.init(library)
     for af in SONGS:
         af.sanitize()
     library.add(SONGS)
     self.bar = self.Bar(library, False)
开发者ID:silkecho,项目名称:glowing-silk,代码行数:10,代码来源:test_browsers_paned.py

示例7: setUp

 def setUp(self):
     self.tempdir = mkdtemp()
     self.pm = PluginManager(folders=[self.tempdir])
     self.lib = SongLibrarian()
     lib = SongLibrary()
     lib.librarian = self.lib
     self.songlist = SongList(library=lib)
     self.player = player.init_player("nullbe", self.lib)
     self.handler = EventPluginHandler(
         librarian=self.lib, player=self.player, songlist=self.songlist)
     self.pm.register_handler(self.handler)
     self.pm.rescan()
     self.assertEquals(self.pm.plugins, [])
开发者ID:LudoBike,项目名称:quodlibet,代码行数:13,代码来源:test_plugins_events.py

示例8: TAudioFeeds

class TAudioFeeds(TestCase):
    def setUp(self):
        quodlibet.config.init()
        self.library = SongLibrary()
        self.bar = AudioFeeds(self.library, NullPlayer("fakesink"))

    def test_can_filter(self):
        for key in ["foo", "title", "fake~key", "~woobar", "~#huh"]:
            self.failIf(self.bar.can_filter(key))

    def tearDown(self):
        self.bar.destroy()
        self.library.destroy()
        quodlibet.config.quit()
开发者ID:silkecho,项目名称:glowing-silk,代码行数:14,代码来源:test_browsers_audiofeeds.py

示例9: TPlaylists

class TPlaylists(TestCase):
    def setUp(self):
        quodlibet.config.init()
        self.library = SongLibrary()
        self.bar = PlaylistsBrowser(SongLibrary())

    def test_can_filter(self):
        for key in ["foo", "title", "fake~key", "~woobar", "~#huh"]:
            self.failIf(self.bar.can_filter(key))

    def tearDown(self):
        self.bar.destroy()
        self.library.destroy()
        quodlibet.config.quit()
开发者ID:brunob,项目名称:quodlibet,代码行数:14,代码来源:test_browsers_playlists.py

示例10: TLyricsPane

class TLyricsPane(TestCase):

    def setUp(self):
        quodlibet.config.init()
        init_fake_app()
        self.pane = None
        self.library = SongLibrary()

    def tearDown(self):
        destroy_fake_app()
        self.library.destroy()
        quodlibet.config.quit()
        if self.pane:
            self.pane.destroy()

    def test_construction(self):
        af = AF({"~filename": fsnative(u"/dev/null")})
        self.pane = LyricsPane(af)

    def test_save_lyrics(self):
        af = self.temp_mp3()
        self.pane = LyricsPane(af)
        self.pane._save_lyrics(af, LYRICS)
        self.failUnlessEqual(af("~lyrics"), LYRICS)

    def test_save_encoded_lyrics(self):
        af = self.temp_mp3()
        self.pane = LyricsPane(af)
        self.pane._save_lyrics(af, LYRICS)
        self.failUnlessEqual(af("~lyrics"), LYRICS)

    def test_save_lyrics_deletes_lyric_file(self):
        af = self.temp_mp3()
        lf_name = af.lyric_filename
        os.makedirs(os.path.dirname(lf_name))
        with open(lf_name, "wb") as f:
            f.write(LYRICS.encode("utf-8"))
        self.failUnless(os.path.exists(lf_name))
        self.pane = LyricsPane(af)
        self.pane._save_lyrics(af, LYRICS)
        self.failIf(os.path.exists(lf_name))

    def temp_mp3(self):
        name = get_temp_copy(get_data_path('silence-44-s.mp3'))
        af = MP3File(name)
        af.sanitize()
        return af
开发者ID:LudoBike,项目名称:quodlibet,代码行数:47,代码来源:test_qltk_lyrics.py

示例11: setUp

    def setUp(self):
        self.library = SongLibrary()
        quodlibet.player.init("nullbe")
        self.device = quodlibet.player.init_device(self.library)

        self.songs = [AudioFile({"title": x}) for x in ["song1", "song2", "song3"]]
        for song in self.songs:
            song.sanitize(song["title"])
开发者ID:silkecho,项目名称:glowing-silk,代码行数:8,代码来源:test_qltk_songsmenu.py

示例12: setUp

 def setUp(self):
     config.RATINGS = config.HardCodedRatingsPrefs()
     self.failUnlessEqual(config.RATINGS.number, NUM_RATINGS)
     self.library = SongLibrary()
     self.library.librarian = SongLibrarian()
     self.af = AudioFile({"~filename": fsnative(u"/foo"), "~#rating": 1.0})
     self.af.sanitize()
     self.rmi = RatingsMenuItem([self.af], self.library)
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:8,代码来源:test_qltk_ratingsmenu.py

示例13: test_save_restore

    def test_save_restore(self):
        player = NullPlayer()
        lib = SongLibrary()
        lib.librarian = None
        lib.add([DUMMY_SONG])

        try:
            os.unlink(QUEUE)
        except OSError:
            pass

        q = PlayQueue(lib, player)
        q.get_model().append(row=[DUMMY_SONG])
        q.destroy()

        q = PlayQueue(lib, player)
        model = q.get_model()
        assert model.values()[0] is DUMMY_SONG
开发者ID:LudoBike,项目名称:quodlibet,代码行数:18,代码来源:test_qltk_queue.py

示例14: setUp

    def setUp(self):
        config.init()
        self.library = SongLibrary()
        backend = quodlibet.player.init_backend("nullbe")
        self.device = backend.init(self.library)

        self.songs = [AudioFile({"title": x}) for x in ["song1", "song2", "song3"]]
        for song in self.songs:
            song.sanitize(fsnative(unicode(song["title"])))
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:9,代码来源:test_qltk_songsmenu.py

示例15: setUp

    def setUp(self):
        config.init()
        config.set("browsers", "panes", "artist")
        library = SongLibrary()
        library.librarian = SongLibrarian()
        PanedBrowser.init(library)
        for af in SONGS:
            af.sanitize()
        library.add(SONGS)
        self.bar = self.Bar(library)

        self.last = None
        self.emit_count = 0

        def selected_cb(browser, songs, *args):
            self.last = list(songs)
            self.emit_count += 1
        self.bar.connect("songs-selected", selected_cb)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:18,代码来源:test_browsers_paned.py


注:本文中的quodlibet.library.SongLibrary类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。