def load(self): if os.path.exists(self._file_path): try: with codecs.open(self._file_path, 'rb', encoding='utf-8') as f: self._cache_list = json.load(f) except Exception as e: self._logger.error(u"Failed to load cache file %s: %s", self._file_path, repr(e)) else: self._cache_list = list() self._initial_cache_size = len(self._cache_list)
def initialize(self): # load existing rss_feeds if os.path.exists(self._rss_file_path): self._logger.debug(u"loading existing channel rss list from %s...", self._rss_file_path) with codecs.open(self._rss_file_path, 'rb', encoding='utf8') as f: rss_list = json.load(f) for rss_url in rss_list: self._rss_feed_dict[rss_url] = None if self._is_created: # create rss-parsers for rss_feed_url in self._rss_feed_dict: rss_parser = ChannelRssParser(self._session, self._channel_community, rss_feed_url) rss_parser.initialize() self._rss_feed_dict[rss_feed_url] = rss_parser else: # subscribe to the channel creation event self._session.add_observer(self._on_channel_created, SIGNAL_CHANNEL, [SIGNAL_ON_CREATED])