当前位置: 首页>>代码示例>>Python>>正文


Python InfoCache.add方法代码示例

本文整理汇总了Python中lollypop.cache.InfoCache.add方法的典型用法代码示例。如果您正苦于以下问题:Python InfoCache.add方法的具体用法?Python InfoCache.add怎么用?Python InfoCache.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lollypop.cache.InfoCache的用法示例。


在下文中一共展示了InfoCache.add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_content

# 需要导入模块: from lollypop.cache import InfoCache [as 别名]
# 或者: from lollypop.cache.InfoCache import add [as 别名]
 def set_content(self, prefix, content, image_url, suffix):
     """
         populate widget with content
         @param prefix as str
         @param content as str
         @param image url as str
         @param suffix as str
         @thread safe
     """
     try:
         data = None
         stream = None
         if content is not None:
             if image_url is not None:
                 f = Lio.File.new_for_uri(image_url)
                 (status, data, tag) = f.load_contents(self.__cancel)
                 if status:
                     stream = Gio.MemoryInputStream.new_from_data(data,
                                                                  None)
                 else:
                     data = None
             InfoCache.add(prefix, content, data, suffix)
         GLib.idle_add(self.__set_content, content, stream)
     except Exception as e:
         print("InfoContent::set_content: %s" % e)
开发者ID:TainakaDrums,项目名称:lollypop,代码行数:27,代码来源:widgets_info.py

示例2: _on_button_clicked

# 需要导入模块: from lollypop.cache import InfoCache [as 别名]
# 或者: from lollypop.cache.InfoCache import add [as 别名]
 def _on_button_clicked(self, button):
     """
         Show file chooser
         @param button as Gtk.button
     """
     dialog = Gtk.FileChooserDialog()
     dialog.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
     dialog.add_buttons(Gtk.STOCK_OPEN, Gtk.ResponseType.OK)
     dialog.set_transient_for(Lp().window)
     self.__close_popover()
     response = dialog.run()
     if response == Gtk.ResponseType.OK:
         try:
             f = Lio.File.new_for_path(dialog.get_filename())
             (status, data, tag) = f.load_contents()
             if not status:
                 raise
             if self.__album is not None:
                 Lp().art.save_album_artwork(data, self.__album.id)
             else:
                 for suffix in ["lastfm", "wikipedia", "spotify"]:
                     InfoCache.uncache_artwork(self.__artist, suffix,
                                               button.get_scale_factor())
                     InfoCache.add(self.__artist, None, data, suffix)
                 Lp().art.emit('artist-artwork-changed', self.__artist)
             self._streams = {}
         except Exception as e:
             print("ArtworkSearch::_on_button_clicked():", e)
     dialog.destroy()
开发者ID:TainakaDrums,项目名称:lollypop,代码行数:31,代码来源:art_widgets.py

示例3: _on_reset_confirm

# 需要导入模块: from lollypop.cache import InfoCache [as 别名]
# 或者: from lollypop.cache.InfoCache import add [as 别名]
 def _on_reset_confirm(self, button):
     """
         Reset cover
         @param button as Gtk.Button
     """
     self._infobar.hide()
     if self.__album is not None:
         Lp().art.remove_album_artwork(self.__album)
         Lp().art.clean_album_cache(self.__album)
         Lp().art.emit('album-artwork-changed', self.__album.id)
     else:
         for suffix in ["lastfm", "wikipedia", "spotify", "deezer"]:
             InfoCache.uncache_artwork(self.__artist, suffix,
                                       button.get_scale_factor())
             InfoCache.add(self.__artist, None, None, suffix)
             Lp().art.emit('artist-artwork-changed', self.__artist)
     self.__close_popover()
开发者ID:TainakaDrums,项目名称:lollypop,代码行数:19,代码来源:art_widgets.py

示例4: __on_activate

# 需要导入模块: from lollypop.cache import InfoCache [as 别名]
# 或者: from lollypop.cache.InfoCache import add [as 别名]
 def __on_activate(self, flowbox, child):
     """
         Use pixbuf as cover
         Reset cache and use player object to announce cover change
     """
     try:
         data = self.__datas[child.get_child()]
         self.__close_popover()
         if self.__album is not None:
             Lp().art.save_album_artwork(data, self.__album.id)
         else:
             for suffix in ["lastfm", "wikipedia", "spotify"]:
                 InfoCache.uncache_artwork(self.__artist, suffix,
                                           flowbox.get_scale_factor())
                 InfoCache.add(self.__artist, None, data, suffix)
             Lp().art.emit('artist-artwork-changed', self.__artist)
         self._streams = {}
     except:
         self._infobar_label.set_text(_("Reset artwork?"))
         self._infobar.show()
         # GTK 3.20 https://bugzilla.gnome.org/show_bug.cgi?id=710888
         self._infobar.queue_resize()
开发者ID:TainakaDrums,项目名称:lollypop,代码行数:24,代码来源:art_widgets.py

示例5: __cache_artists_info

# 需要导入模块: from lollypop.cache import InfoCache [as 别名]
# 或者: from lollypop.cache.InfoCache import add [as 别名]
 def __cache_artists_info(self):
     """
         Cache info for all artists
     """
     # We create cache if needed
     InfoCache.init()
     # Then cache for lastfm/wikipedia/spotify/deezer/...
     for (artist_id, artist, sort) in Lp().artists.get([]):
         if not get_network_available() or\
                 InfoCache.exists(artist):
             continue
         artwork_set = False
         for (api, helper, unused) in InfoCache.WEBSERVICES:
             debug("Downloader::__cache_artists_info(): %[email protected]%s" % (artist,
                                                                  api))
             if helper is None:
                 continue
             try:
                 method = getattr(self, helper)
                 (url, content) = method(artist)
                 if url is not None:
                     s = Lio.File.new_for_uri(url)
                     (status, data, tag) = s.load_contents()
                     if status:
                         artwork_set = True
                         InfoCache.add(artist, content, data, api)
                         debug("Downloader::__cache_artists_info(): %s"
                               % url)
                     else:
                         InfoCache.add(artist, None, None, api)
             except Exception as e:
                 print("Downloader::__cache_artists_info():", e, artist)
                 InfoCache.add(artist, None, None, api)
         if artwork_set:
             GLib.idle_add(Lp().art.emit, 'artist-artwork-changed', artist)
     self.__cache_artists_running = False
开发者ID:TainakaDrums,项目名称:lollypop,代码行数:38,代码来源:downloader.py


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