def test_numexpr_func(self): time = 424242 col = Collection() col.songs = (AudioFile({'~#added': 400000, '~#length': 315}), AudioFile({'~#added': 405000, '~#length': 225})) self.failUnless(NumexprTag('length:avg').evaluate(col, time, True) == 270) self.failUnless(NumexprTag('added:max').evaluate(col, time, True) == 19242)
def namespace_for(song_wrappers): files = [song('~filename') for song in song_wrappers] song_dicts = [song._song for song in song_wrappers] collection = Collection() collection.songs = song_dicts return { 'songs': song_wrappers, 'files': files, 'sdict': song_dicts, 'col': collection, 'app': app}
def __init__(self, songs): Gtk.Window.__init__(self) files = [song('~filename') for song in songs] song_dicts = [song._song for song in songs] collection = Collection() collection.songs = song_dicts self.set_size_request(700, 500) from quodlibet import app console = PythonConsole( namespace={ 'songs': songs, 'files': files, 'sdict': song_dicts, 'col': collection, 'app': app}) self.add(console) access_string = _("You can access the following objects by default:") access_string += "\\n".join([ "", " %5s: SongWrapper objects", " %5s: Song dictionaries", " %5s: Filename list", " %5s: Songs Collection", " %5s: Application instance"]) % ( "songs", "sdict", "files", "col", "app") dir_string = _("Your current working directory is:") if PY2: console.eval("from __future__ import print_function", False) console.eval("import mutagen", False) console.eval("import os", False) console.eval("print(\"Python: %s / Quod Libet: %s\")" % (sys.version.split()[0], const.VERSION), False) console.eval("print(\"%s\")" % access_string, False) console.eval("print(\"%s \"+ os.getcwd())" % dir_string, False) console.connect("destroy", lambda *x: self.destroy())
"genre": "J-Pop", "~filename": "/bin/foo", "foo": "bar\nnope" }), AudioFile({ "title": "xxx", "~filename": "/bin/bar", "foo": "bar" }), ] SONGS.sort() UNKNOWN_ARTIST = AudioFile(dict(SONGS[0])) del UNKNOWN_ARTIST["artist"] ALBUM = Collection() ALBUM.songs = SONGS class TPanedBrowser(TestCase): Bar = PanedBrowser 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)