• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python quodlibet.print_d函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了print_d函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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")
开发者ID:bossjones,项目名称:quodlibet,代码行数:34,代码来源:completion.py


示例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)
开发者ID:LudoBike,项目名称:quodlibet,代码行数:28,代码来源:viewlyrics.py


示例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)
开发者ID:silkecho,项目名称:glowing-silk,代码行数:7,代码来源:_library.py


示例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
开发者ID:zsau,项目名称:quodlibet,代码行数:7,代码来源:duplicates.py


示例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:]
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:29,代码来源:server.py


示例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)
开发者ID:silkecho,项目名称:glowing-silk,代码行数:32,代码来源:_library.py


示例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
开发者ID:MikeiLL,项目名称:quodlibet,代码行数:29,代码来源:auto_library_update.py


示例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)
开发者ID:MikeiLL,项目名称:quodlibet,代码行数:27,代码来源:website_search.py


示例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
开发者ID:zsau,项目名称:quodlibet,代码行数:32,代码来源:duplicates.py


示例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
开发者ID:silkecho,项目名称:glowing-silk,代码行数:7,代码来源:_library.py


示例11: close

    def close(self):
        if self._client is None:
            return

        print_d("Disconnecting from XSMP")
        self._client.close()
        self._client = None
开发者ID:LudoBike,项目名称:quodlibet,代码行数:7,代码来源:xsmp.py


示例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()
开发者ID:urielz,项目名称:quodlibet,代码行数:7,代码来源:repeat.py


示例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
开发者ID:zsau,项目名称:quodlibet,代码行数:26,代码来源:util.py


示例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
开发者ID:zsau,项目名称:quodlibet,代码行数:30,代码来源:audiofeeds.py


示例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
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:29,代码来源:server.py


示例16: _get_saved_searches

 def _get_saved_searches(self):
     filename = self.PATTERNS_FILE + ".saved"
     self._url_pats = StandaloneEditor.load_values(filename)
     # Failing all else...
     if not len(self._url_pats):
         print_d("No saved searches found in %s. Using defaults." %
                 filename, context=self)
         self._url_pats = self.DEFAULT_URL_PATS
开发者ID:MikeiLL,项目名称:quodlibet,代码行数:8,代码来源:website_search.py


示例17: go_to

 def go_to(self, song, explicit=False):
     self.__iter = None
     if isinstance(song, Gtk.TreeIter):
         self.__iter = song
         self.sourced = True
     elif not self.find_row(song):
         print_d("Failed to find song")
     return self.__iter
开发者ID:zsau,项目名称:quodlibet,代码行数:8,代码来源:duplicates.py


示例18: show_files_cb

 def show_files_cb(menu_item):
     print_d("Trying to show files...")
     if not show_songs(songs):
         msg = ErrorMessage(self.plugin_window,
                      _("Unable to show files"),
                      _("Error showing files, "
                        "or no program available to show them."))
         msg.run()
开发者ID:zsau,项目名称:quodlibet,代码行数:8,代码来源:songsmenu.py


示例19: add_to_existing_group

 def add_to_existing_group(self, key, song):
     """Tries to add a song to an existing group. Returns None if not able
     """
     for parent in self:
         if key == parent[0]:
             print_d("Found group", self)
             return self.append(parent.iter, self.__make_row(song))
         # TODO: update group
     return None
开发者ID:zsau,项目名称:quodlibet,代码行数:9,代码来源:duplicates.py


示例20: __init__

 def __init__(self, string, star=None, clock=time.time):
     super(SoundcloudQuery, self).__init__(string, star)
     self._clock = clock
     try:
         self.terms = self._extract_terms(self._match)
     except self.error as e:
         print_d("Couldn't use query: %s" % e)
         self.type = QueryType.INVALID
         self.terms = {}
开发者ID:LudoBike,项目名称:quodlibet,代码行数:9,代码来源:query.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python browsers.get函数代码示例发布时间:2022-05-26
下一篇:
Python quodlibet.ngettext函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap