How to use the rss2email.Feed function in rss2email

To help you get started, we’ve selected a few rss2email examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Dieterbe / rss2email / rss2email.py View on Github external
for line in file:
				fields = line.strip().split()
				if not len(fields):
					continue
				url = fields[0]
				if url[0] == '#':
					logging.debug ("Skipping commented out: %s" % url[1:])
					continue
				settings = None
				to = None
				if (len(fields) > 1):
					to = fields[1]
				# yes, we store the url twice.  not the most efficient, but like this
				# you can do fast lookups and have a normal Feed object
				logging.debug ("loading: %s" % url)
				feeds[url] = Feed(url, to)
	except IOError, e:
		logging.critical ("Feedfile could not be opened: %s", e)
		sys.exit(1)

	# Then, add info about where we left off (seen entries), if available
	if os.path.exists(FEEDS_STATE):
		try:
			statefile = open(FEEDS_STATE, 'r')
		except IOError, e:
			logging.critical ( "Feed state file %s could not be opened: %s", FEEDS_STATE, e)
			sys.exit(1)

		# a dictionary with key url, value: a dict
		feeds_state = pickle.load(statefile)
		for url, seen in feeds_state.items():
			if url in feeds:
github rss2email / rss2email / rss2email.py View on Github external
self._datafile_lock = None

        for feed in self:
            feed.load_from_config(self.config)

        feed_names = set(feed.name for feed in self)
        order = _collections.defaultdict(lambda: (1e3, ''))
        for i,section in enumerate(self.config.sections()):
            if section.startswith('feed.'):
                name = section[len('feed.'):]
                order[name] = (i, name)
                if name not in feed_names:
                    LOG.debug(
                        ('feed {} not found in feed file, '
                         'initializing from config').format(name))
                    self.append(Feed(name=name, config=self.config))
                    feed_names.add(name)
        def key(feed):
            return order[feed.name]
        self.sort(key=key)
github rss2email / rss2email / rss2email.py View on Github external
>>> print(feeds.new_feed(name='my-feed'))
        my-feed (None -> a@b.com)
        >>> print(feeds.new_feed())
        feed-0 (None -> a@b.com)
        >>> print(feeds.new_feed())
        feed-1 (None -> a@b.com)
        """
        if name is None:
            i = 0
            while True:
                name = '{}{}'.format(prefix, i)
                feed_names = [feed.name for feed in self]
                if name not in feed_names:
                    break
                i += 1
        feed = Feed(name=name, **kwargs)
        self.append(feed)
        return feed