Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions planet/reconstitute.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def createTextElement(parent, name, value):
parent.appendChild(xelement)
return xelement

def invalidate(c):
def invalidate(c):
""" replace invalid characters """
return u'<abbr title="U+%s">\ufffd</abbr>' % \
('000' + hex(ord(c.group(0)))[2:])[-4:]
Expand Down Expand Up @@ -81,7 +81,7 @@ def id(xentry, entry):
md5(entry.summary).hexdigest())
elif entry.has_key("content") and entry.content:

entry_id = (entry.content[0].base + "/" +
entry_id = (entry.content[0].base + "/" +
md5(entry.content[0].value).hexdigest())
else:
return
Expand All @@ -94,7 +94,7 @@ def links(xentry, entry):
if not entry.has_key('links'):
entry['links'] = []
if entry.has_key('link'):
entry['links'].append({'rel':'alternate', 'href':entry.link})
entry['links'].append({'rel':'alternate', 'href':entry.link})
xdoc = xentry.ownerDocument
for link in entry['links']:
if not 'href' in link.keys(): continue
Expand Down Expand Up @@ -141,7 +141,7 @@ def author(xentry, name, detail):

createTextElement(xauthor, 'email', detail.get('email', None))
createTextElement(xauthor, 'uri', detail.get('href', None))

xentry.appendChild(xauthor)

def content(xentry, name, detail, bozo):
Expand Down Expand Up @@ -234,7 +234,7 @@ def source(xsource, source, bozo, format):

if not source.has_key('links') and source.has_key('href'): #rss
source['links'] = [{ 'href': source.get('href') }]
if source.has_key('title'):
if source.has_key('title'):
source['links'][0]['title'] = source.get('title')
links(xsource, source)

Expand Down Expand Up @@ -312,7 +312,8 @@ def reconstitute(feed, entry):
location(xentry, (float)(entry.get('geo_long',None)), (float)(entry.get('geo_lat',None)))
if entry.has_key('georss_point'):
coordinates = re.split('[,\s]', entry.get('georss_point'))
location(xentry, (float)(coordinates[1]), (float)(coordinates[0]))
if len(coordinates) >= 2:
location(xentry, (float)(coordinates[1]), (float)(coordinates[0]))
elif entry.has_key('georss_line'):
coordinates = re.split('[,\s]', entry.get('georss_line'))
location(xentry, (float)(coordinates[1]), (float)(coordinates[0]))
Expand Down