def _parse_atom_entry(entry):
title = entry.get('title', None)
elink = entry.get('link', [])
elink = elink if isinstance(elink, list) else [elink]
links = record((link.rel, link.href) for link in elink)
# Retrieve entity content values
content = entry.get('content', {})
# Host entry metadata
metadata = _parse_atom_metadata(content)
# Filter some of the noise out of the content record
content = record((k, v) for k, v in content.iteritems()
if k not in ['eai:acl', 'eai:attributes'])
if 'type' in content:
if isinstance(content['type'], list):
content['type'] = [t for t in content['type'] if t != 'text/xml']
# Unset type if it was only 'text/xml'
if len(content['type']) == 0:
content.pop('type', None)
# Flatten 1 element list
if len(content['type']) == 1:
content['type'] = content['type'][0]
else:
content.pop('type', None)
return record({
'title': title,
'links': links,
'access': metadata.access,
'fields': metadata.fields,
'content': content,
'updated': entry.get("updated")
})
# Parse the metadata fields out of the given atom entry content record
评论列表
文章目录