Ensure planet information makes it into the source element
This commit is contained in:
parent
c20acf9944
commit
316a1afe5e
@ -250,6 +250,7 @@ def reconstitute(feed, entry):
|
|||||||
entry['%s_%s' % (ns,name)])
|
entry['%s_%s' % (ns,name)])
|
||||||
xoriglink.setAttribute('xmlns:%s' % ns, feed.namespaces[ns])
|
xoriglink.setAttribute('xmlns:%s' % ns, feed.namespaces[ns])
|
||||||
|
|
||||||
|
# author / contributor
|
||||||
author_detail = entry.get('author_detail',{})
|
author_detail = entry.get('author_detail',{})
|
||||||
if author_detail and not author_detail.has_key('name') and \
|
if author_detail and not author_detail.has_key('name') and \
|
||||||
feed.feed.has_key('planet_name'):
|
feed.feed.has_key('planet_name'):
|
||||||
@ -258,14 +259,24 @@ def reconstitute(feed, entry):
|
|||||||
for contributor in entry.get('contributors',[]):
|
for contributor in entry.get('contributors',[]):
|
||||||
author(xentry, 'contributor', contributor)
|
author(xentry, 'contributor', contributor)
|
||||||
|
|
||||||
xsource = xdoc.createElement('source')
|
# merge in planet:* from feed (or simply use the feed if no source)
|
||||||
src = entry.get('source') or feed.feed
|
src = entry.get('source')
|
||||||
|
if src:
|
||||||
|
for name,value in feed.feed.items():
|
||||||
|
if name.startswith('planet_'): src[name]=value
|
||||||
|
else:
|
||||||
|
src = feed.feed
|
||||||
|
|
||||||
|
# source:author
|
||||||
src_author = src.get('author_detail',{})
|
src_author = src.get('author_detail',{})
|
||||||
if (not author_detail or not author_detail.has_key('name')) and \
|
if (not author_detail or not author_detail.has_key('name')) and \
|
||||||
not src_author.has_key('name') and feed.feed.has_key('planet_name'):
|
not src_author.has_key('name') and feed.feed.has_key('planet_name'):
|
||||||
if src_author: src_author = src_author.__class__(src_author.copy())
|
if src_author: src_author = src_author.__class__(src_author.copy())
|
||||||
src['author_detail'] = src_author
|
src['author_detail'] = src_author
|
||||||
src_author['name'] = feed.feed['planet_name']
|
src_author['name'] = feed.feed['planet_name']
|
||||||
|
|
||||||
|
# source
|
||||||
|
xsource = xdoc.createElement('source')
|
||||||
source(xsource, src, bozo, feed.version)
|
source(xsource, src, bozo, feed.version)
|
||||||
xentry.appendChild(xsource)
|
xentry.appendChild(xsource)
|
||||||
|
|
||||||
|
11
tests/data/reconstitute/planet_name.xml
Normal file
11
tests/data/reconstitute/planet_name.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<!--
|
||||||
|
Description: planet name
|
||||||
|
Expect: source.planet_name == 'John Doe'
|
||||||
|
-->
|
||||||
|
|
||||||
|
<feed xmlns="http://www.w3.org/2005/Atom"
|
||||||
|
xmlns:planet="http://planet.intertwingly.net/">
|
||||||
|
<planet:name>John Doe</planet:name>
|
||||||
|
<entry/>
|
||||||
|
</feed>
|
||||||
|
|
15
tests/data/reconstitute/planet_name_source.xml
Normal file
15
tests/data/reconstitute/planet_name_source.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<!--
|
||||||
|
Description: ensure that planet attributes make it into the source
|
||||||
|
Expect: source.planet_name == 'John Doe'
|
||||||
|
-->
|
||||||
|
|
||||||
|
<feed xmlns="http://www.w3.org/2005/Atom"
|
||||||
|
xmlns:planet="http://planet.intertwingly.net/">
|
||||||
|
<planet:name>John Doe</planet:name>
|
||||||
|
<entry>
|
||||||
|
<source>
|
||||||
|
<id>http://example.com/</id>
|
||||||
|
</source>
|
||||||
|
</entry>
|
||||||
|
</feed>
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user