From 2cde902af3969e822e35bf3a14a5b66018f3b765 Mon Sep 17 00:00:00 2001 From: David Sveningsson Date: Tue, 15 Feb 2011 15:28:14 +0100 Subject: [PATCH] Only searches for name if planet_name is set. Prints a warning if no matching config is found. --- planet/shell/_genshi.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/planet/shell/_genshi.py b/planet/shell/_genshi.py index fb2a998..7880a3a 100644 --- a/planet/shell/_genshi.py +++ b/planet/shell/_genshi.py @@ -3,7 +3,9 @@ from xml.sax.saxutils import escape from genshi.input import HTMLParser, XMLParser from genshi.template import Context, MarkupTemplate +import planet +log = planet.logger subscriptions = [] feed_types = [ 'application/atom+xml', @@ -28,13 +30,15 @@ def find_config(config, feed): if link.has_key('type') and link.type in feed_types: if link.has_key('href') and link.href in subscriptions: return norm(dict(config.parser.items(link.href))) - + # match based on name - for sub in subscriptions: - if config.parser.has_option(sub, 'name') and \ - norm(config.parser.get(sub, 'name')) == feed.planet_name: - return norm(dict(config.parser.items(sub))) + if 'planet_name' in feed: + for sub in subscriptions: + if config.parser.has_option(sub, 'name') and \ + norm(config.parser.get(sub, 'name')) == feed.planet_name: + return norm(dict(config.parser.items(sub))) + log.warning('Could not match subscription to config: %s', feed.link) return {} class XHTMLParser(object):