本文整理汇总了Python中quodlibet.print_d函数的典型用法代码示例。如果您正苦于以下问题:Python print_d函数的具体用法?Python print_d怎么用?Python print_d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_d函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __build_model
def __build_model(klass, library, model):
print_d("Updating tag model for whole library")
all_tags = klass.__tags
model.clear()
tags = set()
songs = list(library)
for count, song in enumerate(songs):
for tag in song.keys():
if not (tag.startswith("~#") or tag in MACHINE_TAGS):
tags.add(tag)
if count % 500 == 0 or count + 1 == len(songs):
tags -= all_tags
for tag in tags:
model.append([tag])
all_tags.update(tags)
tags.clear()
yield True
tags.update(["~dirname", "~basename", "~people", "~format"])
for tag in ["track", "disc", "playcount", "skipcount", "lastplayed",
"mtime", "added", "rating", "length"]:
tags.add("#(" + tag)
for tag in ["date", "bpm"]:
if tag in all_tags:
tags.add("#(" + tag)
tags -= all_tags
for tag in tags:
model.append([tag])
all_tags.update(tags)
print_d("Done updating tag model for whole library")
示例2: plugin_on_song_started
def plugin_on_song_started(self, song):
"""Called when a song is started. Loads the lyrics.
If there are lyrics associated with `song`, load them into the
lyrics viewer. Otherwise, hides the lyrics viewer.
"""
lyrics = None
if song is not None:
print_d("Looking for lyrics for %s" % song("~filename"))
lyrics = song("~lyrics")
if lyrics:
self.textbuffer.set_text(lyrics)
self.adjustment.set_value(0) # Scroll to the top.
self.textview.show()
else:
title = _("No lyrics found for\n %s") % song("~basename")
self._set_italicised(title)
def edit(widget):
print_d("Launching lyrics editor for %s" % song("~filename"))
assert isinstance(song, SongWrapper)
information = Information(app.librarian, [song._song])
information.get_child()._switch_to_lyrics()
information.show()
if self._sig:
self._edit_button.disconnect(self._sig)
self._sig = self._edit_button.connect('clicked', edit)
示例3: _changed
def _changed(self, items):
# Called by the changed method and Librarians.
if not items:
return
print_d("Changing %d items." % len(items), self)
self.dirty = True
self.emit('changed', items)
示例4: __quit
def __quit(self, widget=None, response=None):
if response == Gtk.ResponseType.OK or \
response == Gtk.ResponseType.CLOSE:
print_d("Exiting plugin on user request...")
self.finished = True
self.destroy()
return
示例5: __request
def __request(self, line, raw=False, want_reply=True):
"""
Send a request to the server, if connected, and return its response
"""
line = line.strip()
if not (self.is_connected or line.split()[0] == 'login'):
print_d("Can't do '%s' - not connected" % line.split()[0], self)
return None
if self._debug:
print_(">>>> \"%s\"" % line)
try:
self.telnet.write(line + "\n")
if not want_reply:
return None
raw_response = self.telnet.read_until("\n").strip()
except socket.error as e:
print_w("Couldn't communicate with squeezebox (%s)" % e)
self.failures += 1
if self.failures >= self._MAX_FAILURES:
print_w("Too many Squeezebox failures. Disconnecting")
self.is_connected = False
return None
response = raw_response if raw else urllib.unquote(raw_response)
if self._debug:
print_("<<<< \"%s\"" % (response,))
return response[len(line) - 1:] if line.endswith("?")\
else response[len(line) + 1:]
示例6: load
def load(self, filename, skip=False):
"""Load a library from a file, containing a picked list.
Loading does not cause added, changed, or removed signals.
"""
self.filename = filename
print_d("Loading contents of %r." % filename, self)
try:
if os.path.exists(filename):
# pickle makes 1000 read syscalls for 6000 songs
# read the file into memory so that there are less
# context switches. saves 40% here..
fileobj = file(filename, "rb")
try: items = pickle.loads(fileobj.read())
except (pickle.PickleError, EnvironmentError,
ImportError, EOFError):
util.print_exc()
try: shutil.copy(filename, filename + ".not-valid")
except EnvironmentError:
util.print_exc()
items = []
fileobj.close()
else: return
except EnvironmentError:
return
if skip:
for item in filter(skip, items):
self._contents[item.key] = item
else:
map(self._load, items)
print_d("Done loading contents of %r." % filename, self)
示例7: enabled
def enabled(self):
if not self.running:
wm = WatchManager()
self.event_handler = LibraryEvent(app.library)
# Choose event types to watch for
# FIXME: watch for IN_CREATE or for some reason folder copies
# are missed, --nickb
FLAGS = ['IN_DELETE', 'IN_CLOSE_WRITE',# 'IN_MODIFY',
'IN_MOVED_FROM', 'IN_MOVED_TO', 'IN_CREATE']
mask = reduce(lambda x, s: x | EventsCodes.ALL_FLAGS[s], FLAGS, 0)
if self.USE_THREADS:
print_d("Using threaded notifier")
self.notifier = ThreadedNotifier(wm, self.event_handler)
# Daemonize to ensure thread dies on exit
self.notifier.daemon = True
self.notifier.start()
else:
self.notifier = Notifier(wm, self.event_handler, timeout=100)
GLib.timeout_add(1000, self.unthreaded_callback)
for path in get_scan_dirs():
print_d('Watching directory %s for %s' % (path, FLAGS))
# See https://github.com/seb-m/pyinotify/wiki/
# Frequently-Asked-Questions
wm.add_watch(path, mask, rec=True, auto_add=True)
self.running = True
示例8: plugin_songs
def plugin_songs(self, songs):
# Check this is a launch, not a configure
if self.chosen_site:
url_pat = self.get_url_pattern(self.chosen_site)
pat = Pattern(url_pat)
urls = set()
for song in songs:
# Generate a sanitised AudioFile; allow through most tags
subs = AudioFile()
for k in (USER_TAGS + MACHINE_TAGS):
vals = song.comma(k)
if vals:
try:
subs[k] = quote_plus(unicode(vals).encode('utf-8'))
# Dodgy unicode problems
except KeyError:
print_d("Problem with %s tag values: %r"
% (k, vals))
url = str(pat.format(subs))
if not url:
print_w("Couldn't build URL using \"%s\"."
"Check your pattern?" % url_pat)
return
# Grr, set.add() should return boolean...
if url not in urls:
urls.add(url)
website(url)
示例9: plugin_songs
def plugin_songs(self, songs):
model = DuplicatesTreeModel()
self.__cfg_cache = {}
# Index all songs by our custom key
# TODO: make this cache-friendly
print_d("Calculating duplicates for %d song(s)..." % len(songs))
groups = {}
for song in songs:
key = self.get_key(song)
if key and key in groups:
print_d("Found duplicate based on '%s'" % key)
groups[key].add(song._song)
elif key:
groups[key] = {song._song}
for song in app.library:
key = self.get_key(song)
if key in groups:
groups[key].add(song)
# Now display the grouped duplicates
for (key, children) in groups.items():
if len(children) < self.MIN_GROUP_SIZE:
continue
# The parent (group) label
model.add_group(key, children)
dialog = DuplicateDialog(model)
dialog.show()
# Mainly for testing...
return dialog
示例10: _load
def _load(self, item):
"""Load a item. Return (changed, removed)."""
# Subclases 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
示例11: close
def close(self):
if self._client is None:
return
print_d("Disconnecting from XSMP")
self._client.close()
self._client = None
示例12: next
def next(self, playlist, iter):
next = self.wrapped.next(playlist, iter)
if next:
return next
self.wrapped.reset(playlist)
print_d("Restarting songlist")
return playlist.get_iter_first()
示例13: __create_playlist
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
示例14: _check_feed
def _check_feed(self):
"""Validate stream a bit - failing fast where possible.
Constructs an equivalent(ish) HEAD request,
without re-writing feedparser completely.
(it never times out if reading from a stream - see #2257)"""
req = feedparser._build_urllib2_request(
self.uri, feedparser.USER_AGENT, None, None, None, None, {})
req.method = "HEAD"
opener = build_opener(feedparser._FeedURLHandler())
try:
result = opener.open(req)
ct_hdr = result.headers.get('Content-Type', "Unknown type")
content_type = ct_hdr.split(';')[0]
try:
status = result.status
except AttributeError:
print_w("Missing status code for feed %s" % self.uri)
else:
print_d("Pre-check: %s returned %s with content type '%s'" %
(self.uri, status, content_type))
if content_type not in feedparser.ACCEPT_HEADER:
print_w("Unusable content: %s. Perhaps %s is not a feed?" %
(content_type, self.uri))
return False
# No real need to check HTTP Status - errors are very unlikely
# to be a usable content type, and we should try to parse
finally:
opener.close()
return True
示例15: 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