From: W. Trevor King Date: Mon, 29 Oct 2012 19:02:44 +0000 (-0400) Subject: rss2email: allow config feed ordering to override datafile ordering X-Git-Tag: v3.0~72^2~1 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a37147e49198b39b437d58f8886160620ce1353e;p=rss2email.git rss2email: allow config feed ordering to override datafile ordering --- diff --git a/rss2email.py b/rss2email.py index 2099921..8f8f5d6 100755 --- a/rss2email.py +++ b/rss2email.py @@ -1367,15 +1367,20 @@ class Feeds (list): feed.load_from_config(self.config) feed_names = set(feed.name for feed in self) - for section in self.config.sections(): + 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) def save(self): LOG.debug('save feed configuration to {}'.format(self.configfiles[-1]))