コード例 #1
0
ファイル: cache.py プロジェクト: synctext/tribler
 def save(self):
     if self._initial_cache_size == len(self._cache_list):
         return
     try:
         with codecs.open(self._file_path, 'wb', encoding='utf-8') as f:
             json.dump(self._cache_list, f)
             self._initial_cache_size = len(self._cache_list)
     except Exception as e:
         self._logger.error(u"Failed to save cache file %s: %s", self._file_path, repr(e))
         return
コード例 #2
0
ファイル: cache.py プロジェクト: ankushshr1993/EDMP
 def save(self):
     if self._initial_cache_size == len(self._cache_list):
         return
     try:
         with codecs.open(self._file_path, 'wb', encoding='utf-8') as f:
             json.dump(self._cache_list, f)
             self._initial_cache_size = len(self._cache_list)
     except Exception as e:
         self._logger.error(u"Failed to save cache file %s: %s",
                            self._file_path, repr(e))
         return
コード例 #3
0
ファイル: channel.py プロジェクト: yanheven/tribler
    def create_rss_feed(self, rss_feed_url):
        if rss_feed_url in self._rss_feed_dict:
            self._logger.warn(u"skip existing rss feed: %s", repr(rss_feed_url))
            return

        if not self._is_created:
            # append the rss url if the channel has not been created yet
            self._rss_feed_dict[rss_feed_url] = None
        else:
            # create an rss feed parser for this
            rss_parser = ChannelRssParser(self._session, self._channel_community, rss_feed_url)
            rss_parser.initialize()
            self._rss_feed_dict[rss_feed_url] = rss_parser

        # flush the rss_feed_url to json file
        with codecs.open(self._rss_file_path, 'wb', encoding='utf8') as f:
            rss_list = [rss_url for rss_url in self._rss_feed_dict.iterkeys()]
            json.dump(rss_list, f)
コード例 #4
0
ファイル: channel.py プロジェクト: synctext/tribler
    def create_rss_feed(self, rss_feed_url):
        if rss_feed_url in self._rss_feed_dict:
            self._logger.warn(u"skip existing rss feed: %s", repr(rss_feed_url))
            return

        if not self._is_created:
            # append the rss url if the channel has not been created yet
            self._rss_feed_dict[rss_feed_url] = None
        else:
            # create an rss feed parser for this
            rss_parser = ChannelRssParser(self._session, self._channel_community, rss_feed_url)
            rss_parser.initialize()
            self._rss_feed_dict[rss_feed_url] = rss_parser

        # flush the rss_feed_url to json file
        with codecs.open(self._rss_file_path, 'wb', encoding='utf8') as f:
            rss_list = [rss_url for rss_url in self._rss_feed_dict.iterkeys()]
            json.dump(rss_list, f)