From 9f4431880e680e30c94446f0c2e4fc5213df19b7 Mon Sep 17 00:00:00 2001 From: Zhiming Wang Date: Mon, 19 Dec 2016 00:41:01 -0500 Subject: [PATCH] Rename url to uri in Atom feeds According to RFC 4287, there is no atom:url element, only atom:uri, so replace occurrences of atom:url with atom:uri for compliance. Also rename variables holding atom:uri from email to uri to better indicate what they actually are. --- feedgen/entry.py | 8 ++++---- feedgen/feed.py | 10 +++++----- tests/test_feed.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/feedgen/entry.py b/feedgen/entry.py index d1286c1..ef5dee3 100644 --- a/feedgen/entry.py +++ b/feedgen/entry.py @@ -90,8 +90,8 @@ class FeedEntry(object): email = etree.SubElement(author, 'email') email.text = a.get('email') if a.get('uri'): - email = etree.SubElement(author, 'url') - email.text = a.get('uri') + uri = etree.SubElement(author, 'uri') + uri.text = a.get('uri') if self.__atom_content: content = etree.SubElement(entry, 'content') @@ -156,8 +156,8 @@ class FeedEntry(object): email = etree.SubElement(contrib, 'email') email.text = c.get('email') if c.get('uri'): - email = etree.SubElement(contrib, 'url') - email.text = c.get('uri') + uri = etree.SubElement(contrib, 'uri') + uri.text = c.get('uri') if self.__atom_published: published = etree.SubElement(entry, 'published') diff --git a/feedgen/feed.py b/feedgen/feed.py index 18b5b18..58f1847 100644 --- a/feedgen/feed.py +++ b/feedgen/feed.py @@ -47,7 +47,7 @@ class FeedGenerator(object): self.__atom_contributor = None self.__atom_generator = { 'value' :'python-feedgen', - 'url' :'http://lkiesow.github.io/python-feedgen', + 'uri' :'http://lkiesow.github.io/python-feedgen', 'version':feedgen.version.version_str } #{value*,uri,version} self.__atom_icon = None self.__atom_logo = None @@ -124,8 +124,8 @@ class FeedGenerator(object): email = etree.SubElement(author, 'email') email.text = a.get('email') if a.get('uri'): - email = etree.SubElement(author, 'url') - email.text = a.get('uri') + uri = etree.SubElement(author, 'uri') + uri.text = a.get('uri') for l in self.__atom_link or []: link = etree.SubElement(feed, 'link', href=l['href']) @@ -159,8 +159,8 @@ class FeedGenerator(object): email = etree.SubElement(contrib, 'email') email.text = c.get('email') if c.get('uri'): - email = etree.SubElement(contrib, 'url') - email.text = c.get('uri') + uri = etree.SubElement(contrib, 'uri') + uri.text = c.get('uri') if self.__atom_generator: generator = etree.SubElement(feed, 'generator') diff --git a/tests/test_feed.py b/tests/test_feed.py index 7c70760..8d18e3b 100644 --- a/tests/test_feed.py +++ b/tests/test_feed.py @@ -215,7 +215,7 @@ class TestSequenceFunctions(unittest.TestCase): assert feed.find("{%s}subtitle" % nsAtom).text == self.subtitle assert feed.find("{%s}contributor" % nsAtom).find("{%s}name" % nsAtom).text == self.contributor['name'] assert feed.find("{%s}contributor" % nsAtom).find("{%s}email" % nsAtom).text == self.contributor['email'] - assert feed.find("{%s}contributor" % nsAtom).find("{%s}url" % nsAtom).text == self.contributor['uri'] + assert feed.find("{%s}contributor" % nsAtom).find("{%s}uri" % nsAtom).text == self.contributor['uri'] assert feed.find("{%s}rights" % nsAtom).text == self.copyright def test_rssFeedFile(self):