From 6ae4fad6e34cc4173be5053c8da041e70631e1dd Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Sun, 22 Oct 2006 18:08:56 -0400 Subject: [PATCH] Handle WordPress Link Manager dialect of OPML --- THANKS | 1 + planet/opml.py | 4 ++++ tests/test_opml.py | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/THANKS b/THANKS index dc58e7b..2699c41 100644 --- a/THANKS +++ b/THANKS @@ -9,6 +9,7 @@ Harry Fuecks - Pipe characters in file names, filter bug Eric van der Vlist - Filters to add language, category information Chris Dolan - mkdir cache; default template_dirs; fix xsltproc David Sifry - rss 2.0 xslt template based on http://atom.geekhood.net/ +Morten Fredericksen - Support WordPress LinkManager OPML This codebase represents a radical refactoring of Planet 2.0, which lists the following contributors: diff --git a/planet/opml.py b/planet/opml.py index d4e9a54..6e0b02a 100755 --- a/planet/opml.py +++ b/planet/opml.py @@ -48,6 +48,10 @@ class OpmlParser(ContentHandler,SGMLParser): # this is an entry in a subscription list, but some leave this # attribute off, and others have placed 'atom' in here if attrs.has_key('type'): + if attrs['type'] == 'link' and not attrs.has_key('url'): + # Auto-correct WordPress link manager OPML files + attrs = dict(attrs.items()) + attrs['type'] = 'rss' if attrs['type'].lower() not in['rss','atom']: return # The feed itself is supposed to be in an attribute named 'xmlUrl' diff --git a/tests/test_opml.py b/tests/test_opml.py index a34a4e8..0111253 100644 --- a/tests/test_opml.py +++ b/tests/test_opml.py @@ -76,6 +76,14 @@ class OpmlTest(unittest.TestCase): text="sample feed"/>''', self.config) self.assertFalse(self.config.has_section("http://example.com/feed.xml")) + def test_WordPress_link_manager(self): + # http://www.wasab.dk/morten/blog/archives/2006/10/22/wp-venus + opml2config('''''', self.config) + self.assertEqual('sample feed', + self.config.get("http://example.com/feed.xml", 'name')) + # # xmlUrl #