本文整理汇总了Python中quodlibet.util.dprint.print_d函数的典型用法代码示例。如果您正苦于以下问题:Python print_d函数的具体用法?Python print_d怎么用?Python print_d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_d函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search_complete
def search_complete(self, res):
self.disconnect(sci)
if res:
print_d(res)
self.download(Soup.Message.new('GET', res[0]))
else:
return self.fail('No cover was found')
示例2: _load_item
def _load_item(self, item):
"""Load (add) an item into this library"""
# Subclasses should override this if they want to check
# item validity; see `FileLibrary`.
print_d("Loading %r." % item.key, self)
self.dirty = True
self._contents[item.key] = item
示例3: check_wrapper_changed
def check_wrapper_changed(library, parent, songs):
needs_write = filter(lambda s: s._needs_write, songs)
if needs_write:
win = WritingWindow(parent, len(needs_write))
win.show()
for song in needs_write:
try:
song._song.write()
except AudioFileError as e:
qltk.ErrorMessage(
None, _("Unable to edit song"),
_("Saving <b>%s</b> failed. The file "
"may be read-only, corrupted, or you "
"do not have permission to edit it.") %
util.escape(song('~basename'))).run()
print_d("Couldn't save song %s (%s)" % (song("~filename"), e))
if win.step():
break
win.destroy()
changed = []
for song in songs:
if song._was_updated():
changed.append(song._song)
elif not song.valid() and song.exists():
library.reload(song._song)
library.changed(changed)
示例4: get_players
def get_players(self):
""" Returns (and caches) a list of the Squeezebox players available"""
if self.players:
return self.players
pairs = self.__request("players 0 99", True).split(" ")
def demunge(string):
s = urllib.unquote(string)
cpos = s.index(":")
return (s[0:cpos], s[cpos + 1:])
# Do a meaningful URL-unescaping and tuplification for all values
pairs = map(demunge, pairs)
# First element is always count
count = int(pairs.pop(0)[1])
self.players = []
for pair in pairs:
if pair[0] == "playerindex":
playerindex = int(pair[1])
self.players.append(SqueezeboxPlayerSettings())
else:
# Don't worry playerindex is always the first entry...
self.players[playerindex][pair[0]] = pair[1]
if self._debug:
print_d("Found %d player(s): %s" %
(len(self.players), self.players))
assert (count == len(self.players))
return self.players
示例5: get_data
def get_data(self, key):
"""Gets the pattern for a given key"""
try:
return self.commands[key]
except (KeyError, TypeError):
print_d("Invalid key %s" % key)
return None
示例6: remove_songs
def remove_songs(self, songs, library, leave_dupes=False):
"""
Removes `songs` from this playlist if they are there,
removing only the first reference if `leave_dupes` is True
"""
changed = False
for song in songs:
# TODO: document the "library.masked" business
if library.masked(song("~filename")):
while True:
try:
self[self.index(song)] = song("~filename")
except ValueError:
break
else:
changed = True
else:
while song in self.songs:
print_d("Removing \"%s\" from playlist \"%s\"..."
% (song["~filename"], self.name))
self.songs.remove(song)
if leave_dupes:
changed = True
break
else:
changed = True
# Evict song from cache entirely
try:
del self._song_map_cache[song]
print_d("Removed playlist cache for \"%s\"" % song["~filename"])
except KeyError: pass
return changed
示例7: enable
def enable(self, plugin, status, force=False):
"""Enable or disable a plugin."""
if not force and self.enabled(plugin) == bool(status):
return
if not status:
print_d("Disable %r" % plugin.id)
for handler in plugin.handlers:
handler.plugin_disable(plugin)
self.__enabled.discard(plugin.id)
instance = plugin.instance
if instance and hasattr(instance, "disabled"):
try:
instance.disabled()
except Exception:
util.print_exc()
else:
print_d("Enable %r" % plugin.id)
obj = plugin.get_instance()
if obj and hasattr(obj, "enabled"):
try:
obj.enabled()
except Exception:
util.print_exc()
for handler in plugin.handlers:
handler.plugin_enable(plugin)
self.__enabled.add(plugin.id)
示例8: __init__
def __init__(self, library):
print_d("Creating Soundcloud Browser")
super(SoundcloudBrowser, self).__init__(spacing=12)
self.set_orientation(Gtk.Orientation.VERTICAL)
if not self.instances():
self._init(library)
self._register_instance()
self.connect('destroy', self.__destroy)
self.connect('uri-received', self.__handle_incoming_uri)
self.__auth_sig = self.api_client.connect('authenticated',
self.__on_authenticated)
connect_destroy(self.library, 'changed', self.__changed)
self.login_state = (State.LOGGED_IN if self.online
else State.LOGGED_OUT)
self._create_searchbar(self.library)
vbox = Gtk.VBox()
vbox.pack_start(self._create_footer(), False, False, 6)
vbox.pack_start(self._create_category_widget(), True, True, 0)
vbox.pack_start(self.create_login_button(), False, False, 6)
vbox.show()
pane = qltk.ConfigRHPaned("browsers", "soundcloud_pos", 0.4)
pane.show()
pane.pack1(vbox, resize=False, shrink=False)
self._songs_box = songs_box = Gtk.VBox(spacing=6)
songs_box.pack_start(self._searchbox, False, True, 0)
songs_box.show()
pane.pack2(songs_box, resize=True, shrink=False)
self.pack_start(pane, True, True, 0)
self.show()
示例9: __save
def __save(self, *data):
"""Save the cover and spawn the program to edit it if selected"""
save_format = self.name_combo.get_active_text()
# Allow use of patterns in creating cover filenames
pattern = ArbitraryExtensionFileFromPattern(
save_format.decode("utf-8"))
filename = pattern.format(self.song)
print_d("Using '%s' as filename based on %s" % (filename, save_format))
file_path = os.path.join(self.dirname, filename)
if os.path.exists(file_path):
resp = ConfirmFileReplace(self, file_path).run()
if resp != ConfirmFileReplace.RESPONSE_REPLACE:
return
try:
f = open(file_path, 'wb')
f.write(self.current_data)
f.close()
except IOError:
qltk.ErrorMessage(None, _('Saving failed'),
_('Unable to save "%s".') % file_path).run()
else:
if self.open_check.get_active():
try:
util.spawn([self.cmd.get_text(), file_path])
except:
pass
app.cover_manager.cover_changed([self.song])
self.main_win.destroy()
示例10: send_nowplaying
def send_nowplaying(self):
data = {"s": self.session_id}
for key, val in self.nowplaying_song.items():
data[key] = val.encode("utf-8")
print_d("Now playing song: %s - %s" % (self.nowplaying_song["a"], self.nowplaying_song["t"]))
return self._check_submit(self.nowplaying_url, data)
示例11: add_station
def add_station(uri):
"""Fetches the URI content and extracts IRFiles
Returns None in error, else a possibly filled list of stations"""
irfs = []
if uri.lower().endswith(".pls") or uri.lower().endswith(".m3u"):
try:
sock = urlopen(uri)
except EnvironmentError as err:
err = text_type(err)
print_d("Got %s from %s" % (uri, err))
ErrorMessage(None, _("Unable to add station"), escape(err)).run()
return None
if uri.lower().endswith(".pls"):
irfs = ParsePLS(sock)
elif uri.lower().endswith(".m3u"):
irfs = ParseM3U(sock)
sock.close()
else:
try:
irfs = [IRFile(uri)]
except ValueError as err:
ErrorMessage(None, _("Unable to add station"), err).run()
return irfs
示例12: register_translation
def register_translation(domain, localedir=None):
"""Register a translation domain
Args:
domain (str): the gettext domain
localedir (pathlike): A directory used for translations, if None the
system one will be used.
Returns:
GlibTranslations
"""
global _debug_text, _translations, _initialized
assert _initialized
if localedir is None:
iterdirs = iter_locale_dirs
else:
iterdirs = lambda: iter([localedir])
for dir_ in iterdirs():
try:
t = gettext.translation(domain, dir_, class_=GlibTranslations)
except OSError:
continue
else:
print_d("Translations loaded: %r" % unexpand(t.path))
break
else:
print_d("No translation found for the domain %r" % domain)
t = GlibTranslations()
t.set_debug_text(_debug_text)
_translations[domain] = t
return t
示例13: add_station
def add_station(uri):
"""Fetches the URI content and extracts IRFiles
Returns None in error, else a possibly filled list of stations"""
irfs = []
if uri.lower().endswith(".pls") or uri.lower().endswith(".m3u"):
if not re.match('^([^/:]+)://', uri):
# Assume HTTP if no protocol given. See #2731
uri = 'http://' + uri
print_d("Assuming http: %s" % uri)
try:
sock = urlopen(uri)
except EnvironmentError as err:
err = "%s\n\nURL: %s" % (text_type(err), uri)
print_d("Got %s from %s" % (err, uri))
ErrorMessage(None, _("Unable to add station"), escape(err)).run()
return None
if uri.lower().endswith(".pls"):
irfs = ParsePLS(sock)
elif uri.lower().endswith(".m3u"):
irfs = ParseM3U(sock)
sock.close()
else:
try:
irfs = [IRFile(uri)]
except ValueError as err:
ErrorMessage(None, _("Unable to add station"), err).run()
return irfs
示例14: init
def init():
global device_manager
if not dbus: return
device_manager = None
print_d(_("Initializing device backend."))
try_text = _("Trying '%s'")
#DKD maintainers will change the naming of dbus, app stuff
#in january 2010 or so (already changed in trunk), so try both
if device_manager is None:
print_d(try_text % "DeviceKit Disks")
try: device_manager = DKD(("DeviceKit", "Disks"))
except (LookupError, dbus.DBusException): pass
if device_manager is None:
print_d(try_text % "UDisks")
try: device_manager = DKD(("UDisks",))
except (LookupError, dbus.DBusException): pass
if device_manager is None:
print_d(try_text % "HAL")
try: device_manager = HAL()
except (LookupError, dbus.DBusException): pass
if device_manager is None:
print_w(_("Couldn't connect to a device backend."))
else:
print_d(_("Device backend initialized."))
return device_manager
示例15: __changed_and_signal_library
def __changed_and_signal_library(self, entry, section, name):
config.set(section, name, str(entry.get_value()))
print_d("Signalling \"changed\" to entire library. Hold tight...")
# Cache over clicks
self._songs = self._songs or app.library.values()
copool.add(emit_signal, self._songs, funcid="library changed",
name=_("Updating for new ratings"))