本文整理汇总了Python中quodlibet.qltk.wlw.WaitLoadWindow.step方法的典型用法代码示例。如果您正苦于以下问题:Python WaitLoadWindow.step方法的具体用法?Python WaitLoadWindow.step怎么用?Python WaitLoadWindow.step使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类quodlibet.qltk.wlw.WaitLoadWindow
的用法示例。
在下文中一共展示了WaitLoadWindow.step方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _do_trash_songs
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
def _do_trash_songs(parent, songs, librarian):
dialog = TrashDialog.for_songs(parent, songs)
resp = dialog.run()
if resp != TrashDialog.RESPONSE_TRASH:
return
window_title = _("Moving %(current)d/%(total)d.")
w = WaitLoadWindow(parent, len(songs), window_title)
w.show()
ok = []
failed = []
for song in songs:
filename = song("~filename")
try:
trash.trash(filename)
except trash.TrashError:
failed.append(song)
else:
ok.append(song)
w.step()
w.destroy()
if failed:
ErrorMessage(parent,
_("Unable to move to trash"),
_("Moving one or more files to the trash failed.")
).run()
if ok:
librarian.remove(ok)
示例2: _do_trash_files
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
def _do_trash_files(parent, paths):
dialog = TrashDialog.for_files(parent, paths)
resp = dialog.run()
if resp != TrashDialog.RESPONSE_TRASH:
return
window_title = _("Moving %(current)d/%(total)d.")
w = WaitLoadWindow(parent, len(paths), window_title)
w.show()
ok = []
failed = []
for path in paths:
try:
trash.trash(path)
except trash.TrashError:
failed.append(path)
else:
ok.append(path)
w.step()
w.destroy()
if failed:
ErrorMessage(parent,
_("Unable to move to trash"),
_("Moving one or more files to the trash failed.")
).run()
示例3: _do_delete_songs
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
def _do_delete_songs(parent, songs, librarian):
dialog = DeleteDialog.for_songs(parent, songs)
resp = dialog.run()
if resp != DeleteDialog.RESPONSE_DELETE:
return
window_title = _("Deleting %(current)d/%(total)d.")
w = WaitLoadWindow(parent, len(songs), window_title)
w.show()
ok = []
failed = []
for song in songs:
filename = song("~filename")
try:
os.unlink(filename)
except EnvironmentError:
failed.append(song)
else:
ok.append(song)
w.step()
w.destroy()
if failed:
ErrorMessage(parent,
_("Unable to delete files"),
_("Deleting one or more files failed.")
).run()
if ok:
librarian.remove(ok)
示例4: _do_delete_files
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
def _do_delete_files(parent, paths):
dialog = DeleteDialog.for_files(parent, paths)
resp = dialog.run()
if resp != DeleteDialog.RESPONSE_DELETE:
return
window_title = _("Deleting %(current)d/%(total)d.")
w = WaitLoadWindow(parent, len(paths), window_title)
w.show()
ok = []
failed = []
for path in paths:
try:
os.unlink(path)
except EnvironmentError:
failed.append(path)
else:
ok.append(path)
w.step()
w.destroy()
if failed:
ErrorMessage(parent,
_("Unable to delete files"),
_("Deleting one or more files failed.")
).run()
示例5: test_plurals
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
def test_plurals(self):
with locale_numeric_conv():
wlw = WaitLoadWindow(None, 1234, "At %(current)d of %(total)d")
self.failUnlessEqual(wlw._label.get_text(), "At 0 of 1,234")
while wlw.current < 1000:
wlw.step()
self.failUnlessEqual(wlw._label.get_text(), "At 1,000 of 1,234")
示例6: TWaitLoadWindow
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
class TWaitLoadWindow(TestCase):
class DummyConnector(Gtk.Window):
count = 0
def connect(self, *args):
self.count += 1
def disconnect(self, *args):
self.count -= 1
class Eater:
def set_cursor(*args):
pass
window = Eater()
def setUp(self):
self.parent = self.DummyConnector()
self.wlw = WaitLoadWindow(self.parent, 5, "a test")
def test_none(self):
wlw = WaitLoadWindow(None, 5, "a test")
wlw.step()
wlw.destroy()
def test_plurals(self):
with locale_numeric_conv():
wlw = WaitLoadWindow(None, 1234, "At %(current)d of %(total)d")
self.failUnlessEqual(wlw._label.get_text(), "At 0 of 1,234")
while wlw.current < 1000:
wlw.step()
self.failUnlessEqual(wlw._label.get_text(), "At 1,000 of 1,234")
def test_connect(self):
self.failUnlessEqual(2, self.parent.count)
self.wlw.destroy()
self.failUnlessEqual(0, self.parent.count)
def test_start(self):
self.failUnlessEqual(0, self.wlw.current)
self.failUnlessEqual(5, self.wlw.count)
def test_step(self):
self.failIf(self.wlw.step())
self.failUnlessEqual(1, self.wlw.current)
self.failIf(self.wlw.step())
self.failIf(self.wlw.step())
self.failUnlessEqual(3, self.wlw.current)
def test_destroy(self):
self.wlw.destroy()
self.failUnlessEqual(0, self.parent.count)
def tearDown(self):
self.wlw.destroy()
示例7: TWaitLoadWindow
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
class TWaitLoadWindow(TestCase):
class DummyConnector(Gtk.Window):
count = 0
def connect(self, *args):
self.count += 1
def disconnect(self, *args):
self.count -= 1
class Eater:
def set_cursor(*args):
pass
window = Eater()
def setUp(self):
self.parent = self.DummyConnector()
self.wlw = WaitLoadWindow(self.parent, 5, "a test")
def test_none(self):
wlw = WaitLoadWindow(None, 5, "a test")
wlw.step()
wlw.destroy()
def test_connect(self):
self.failUnlessEqual(2, self.parent.count)
self.wlw.destroy()
self.failUnlessEqual(0, self.parent.count)
def test_start(self):
self.failUnlessEqual(0, self.wlw.current)
self.failUnlessEqual(5, self.wlw.count)
def test_step(self):
self.failIf(self.wlw.step())
self.failUnlessEqual(1, self.wlw.current)
self.failIf(self.wlw.step())
self.failIf(self.wlw.step())
self.failUnlessEqual(3, self.wlw.current)
def test_destroy(self):
self.wlw.destroy()
self.failUnlessEqual(0, self.parent.count)
def tearDown(self):
self.wlw.destroy()
示例8: __parse_playlist
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
def __parse_playlist(name, plfilename, files, library):
playlist = Playlist.new(PLAYLISTS, name, library=library)
songs = []
win = WaitLoadWindow(None, len(files), _("Importing playlist.\n\n%(current)d/%(total)d songs added."))
win.show()
for i, filename in enumerate(files):
try:
uri = URI(filename)
except ValueError:
if os.name == "nt":
filename = filename.decode("utf-8", "replace")
# Plain filename.
filename = os.path.realpath(os.path.join(os.path.dirname(plfilename), filename))
if library and filename in library:
songs.append(library[filename])
else:
songs.append(formats.MusicFile(filename))
else:
if uri.scheme == "file":
# URI-encoded local filename.
filename = os.path.realpath(os.path.join(os.path.dirname(plfilename), uri.filename))
if library and filename in library:
songs.append(library[filename])
else:
songs.append(formats.MusicFile(filename))
else:
# Who knows! Hand it off to GStreamer.
songs.append(formats.remote.RemoteFile(uri))
if win.step():
break
win.destroy()
playlist.extend(filter(None, songs))
return playlist
示例9: plugin_songs
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
def plugin_songs(self, songs):
if not ConfirmAction(self.plugin_window,
_('Set dacapo Lyric Flag'),
_("Check {!s} files?").format(self.counter)
).run():
logging.debug("Verarbeitung abgebrochen!")
return True
logging.debug("Starte Verarbeitung!")
win = WaitLoadWindow(
self.plugin_window, len(songs),
_("Suche nach Synchronisierten Texten.\n\n%(current)d/%(total)d Songs verarbeitet."))
for song in songs:
logging.debug(u'Song: %s hassynclyrics %s' % (song.list('title'), song.get('hassynclyrics')))
if song.get("~filename", "").endswith(".flac"):
flacFilePath = song.get("~filename", "")
try:
lyrics = self.getLrycs(flacFilePath)
if(lyrics == False):
song["hassynclyrics"] = '0'
else:
song["hassynclyrics"] = '1'
except:
return False
if win.step():
break
win.destroy()
示例10: __create_playlist
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
def __create_playlist(name, source_dir, files, library):
playlist = FileBackedPlaylist.new(PLAYLISTS, name, library=library)
print_d("Created playlist %s" % playlist)
songs = []
win = WaitLoadWindow(
None, len(files),
_("Importing playlist.\n\n%(current)d/%(total)d songs added."))
win.show()
for i, filename in enumerate(files):
if not uri_is_valid(filename):
# Plain filename.
songs.append(_af_for(filename, library, source_dir))
else:
try:
filename = uri2fsn(filename)
except ValueError:
# Who knows! Hand it off to GStreamer.
songs.append(formats.remote.RemoteFile(filename))
else:
# URI-encoded local filename.
songs.append(_af_for(filename, library, source_dir))
if win.step():
break
win.destroy()
playlist.extend(list(filter(None, songs)))
return playlist
示例11: __parse_playlist
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
def __parse_playlist(name, plfilename, files, library):
playlist = FileBackedPlaylist.new(PLAYLISTS, name, library=library)
songs = []
win = WaitLoadWindow(
None, len(files),
_("Importing playlist.\n\n%(current)d/%(total)d songs added."))
win.show()
for i, filename in enumerate(files):
if not uri_is_valid(filename):
# Plain filename.
filename = os.path.realpath(os.path.join(
os.path.dirname(plfilename), filename))
if library and filename in library:
songs.append(library[filename])
else:
songs.append(formats.MusicFile(filename))
else:
try:
filename = uri2fsn(filename)
except ValueError:
# Who knows! Hand it off to GStreamer.
songs.append(formats.remote.RemoteFile(filename))
else:
# URI-encoded local filename.
filename = os.path.realpath(os.path.join(
os.path.dirname(plfilename), filename))
if library and filename in library:
songs.append(library[filename])
else:
songs.append(formats.MusicFile(filename))
if win.step():
break
win.destroy()
playlist.extend(filter(None, songs))
return playlist
示例12: plugin_songs
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
def plugin_songs(self, songs):
if (songs is None) or (len(songs) <= 0):
return True
if not ConfirmAction(self.plugin_window,
_(self.PLUGIN_NAME),
_("Check {!s} files?").format(len(songs))
).run():
return True
win = WaitLoadWindow(
self.plugin_window, len(songs),
_("Counting pictures.\n\n%(current)d/%(total)d Songs done."))
for song in songs:
if song.get("~filename", "").endswith(".flac"):
flacFilePath = song.get("~filename", "")
try:
self.countImages(song)
except:
win.destroy()
self.printError()
return False
if win.step():
break
win.destroy()
示例13: run
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
def run(self):
resp = super(DeleteDialog, self).run()
if self.__askonly:
self.destroy()
return resp
if resp == 1 or resp == gtk.RESPONSE_DELETE_EVENT: return []
elif resp == 0: s = _("Moving %(current)d/%(total)d.")
elif resp == 2: s = _("Deleting %(current)d/%(total)d.")
else: return []
files = self.__files
w = WaitLoadWindow(self, len(files), s)
removed = []
if resp == 0:
for filename in files:
try:
trash.trash(filename)
except trash.TrashError:
fn = util.escape(util.fsdecode(util.unexpand(filename)))
ErrorMessage(self, _("Unable to move to trash"),
(_("Moving <b>%s</b> to the trash failed.") %
fn)).run()
break
removed.append(filename)
w.step()
else:
for filename in files:
try:
os.unlink(filename)
except EnvironmentError, s:
try: s = unicode(s.strerror, const.ENCODING, 'replace')
except TypeError:
s = unicode(s.strerror[1], const.ENCODING, 'replace')
s = "\n\n" + s
fn = util.escape(util.fsdecode(util.unexpand(filename)))
ErrorMessage(
self, _("Unable to delete file"),
(_("Deleting <b>%s</b> failed.") % fn) + s).run()
break
removed.append(filename)
w.step()
示例14: plugin_songs
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
def plugin_songs(self, songs):
for song in songs:
if song.get("~filename", "").endswith(".flac"):
flacFilePath = os.path.dirname(os.path.abspath(song.get("~filename", "")));
break
choose = AddImageFileChooser(self.plugin_window, flacFilePath)
files = choose.run()
desc = choose.get_description()
choose.destroy()
if (files == None) or (len(files) <= 0):
return True
for file in files:
contentType = mimetypes.guess_type(file) # get Mimetype
mimeType = contentType[0]
if (mimeType in self.JPG_MIMES) or (mimeType in self.PNG_MIMES):
img = get_image_size(file)
img.mime = mimeType
img.type = choose.imgType
if (len(desc) <= 0):
img.desc = ntpath.basename(file)
else:
img.desc = desc
self.imgFiles.append(img)
if not ConfirmAction(self.plugin_window,
_(self.PLUGIN_NAME),
_("Add {!s} images as type \n\n<b>>> {!s} <<</b>\n\nto {!s} files?").format(
len(files), choose.TYPE[choose.imgType], self.counter)
).run():
return True
win = WaitLoadWindow(
self.plugin_window, len(songs),
_("Adding Image.\n\n%(current)d/%(total)d Songs done."))
for song in songs:
if song.get("~filename", "").endswith(".flac"):
flacFilePath = song.get("~filename", "")
try:
self.setImage(song)
except:
win.destroy()
printError()
return False
if win.step():
break
win.destroy()
示例15: plugin_songs
# 需要导入模块: from quodlibet.qltk.wlw import WaitLoadWindow [as 别名]
# 或者: from quodlibet.qltk.wlw.WaitLoadWindow import step [as 别名]
def plugin_songs(self, songs):
if os.system("ifp typestring"):
qltk.ErrorMessage(
None, _("No iFP device found"),
_("Unable to contact your iFP device. Check "
"that the device is powered on and plugged "
"in, and that you have ifp-line "
"(http://ifp-driver.sf.net) installed.")).run()
return True
self.__madedir = []
w = WaitLoadWindow(
None, len(songs), _("Uploading %(current)d/%(total)d"))
w.show()
for i, song in enumerate(songs):
if self.__upload(song) or w.step():
w.destroy()
return True
else:
w.destroy()