Permalink
Browse files

Preserve link/title, map rss source to atom source

  • Loading branch information...
1 parent bc72bf5 commit d2f2f8510b4f18c7f95a6b73f64bdb5d79fe492f @rubys committed May 20, 2010
Showing with 16 additions and 17 deletions.
  1. +6 −8 planet/reconstitute.py
  2. +9 −8 planet/splice.py
  3. +1 −1 tests/data/reconstitute/rss_source.xml
View
@@ -103,6 +103,8 @@ def links(xentry, entry):
xlink.setAttribute('type', link.get('type'))
if link.has_key('rel'):
xlink.setAttribute('rel', link.get('rel',None))
+ if link.has_key('title'):
+ xlink.setAttribute('title', link.get('title'))
if link.has_key('length'):
xlink.setAttribute('length', link.get('length'))
xentry.appendChild(xlink)
@@ -229,15 +231,11 @@ def source(xsource, source, bozo, format):
for contributor in source.get('contributors',[]):
author(xsource, 'contributor', contributor)
- links(xsource, source)
if not source.has_key('links') and source.has_key('href'): #rss
- xlink = xdoc.createElement('link')
- xlink.setAttribute('href', source.get('href'))
- xsource.appendChild(xlink)
- if source.has_key('title'):
- xtitle = xdoc.createElement('title')
- xtitle.appendChild(xdoc.createTextNode(source.get('title')))
- xsource.appendChild(xtitle)
+ source['links'] = [{ 'href': source.get('href') }]
+ if source.has_key('title'):
+ source['links'][0]['title'] = source.get('title')
+ links(xsource, source)
content(xsource, 'rights', source.get('rights_detail',None), bozo)
content(xsource, 'subtitle', source.get('subtitle_detail',None), bozo)
View
@@ -59,15 +59,16 @@ def splice():
if data.feed.has_key('id'): sub_ids.append(data.feed.id)
if not data.feed: continue
- for link in data.feed.links:
- if link.rel == 'self': break
- else:
- log.warn('missing self link for ' + sub)
+ if not data.feed.has_key('planet_message'):
+ for link in data.feed.links:
+ if link.rel == 'self': break
+ else:
+ log.warn('missing self link for ' + sub)
- for link in data.feed.links:
- if link.rel == 'alternate' and 'html' in link.type: break
- else:
- log.warn('missing html link for ' + sub)
+ for link in data.feed.links:
+ if link.rel == 'alternate' and 'html' in link.type: break
+ else:
+ log.warn('missing html link for ' + sub)
xdoc=minidom.parseString('''<planet:source xmlns:planet="%s"
xmlns="http://www.w3.org/2005/Atom"/>\n''' % planet.xmlns)
@@ -1,6 +1,6 @@
<!--
Description: source element
-Expect: source.title == 'org'
+Expect: source.links[0].title == 'org' and source.links[0].href == 'http://www.example.org'
-->
<rss version="2.0">

0 comments on commit d2f2f85

Please sign in to comment.