Example #1
0
File: parse.py Project: jab/melkman
def item_trace(e):
    """
    produces a compact subset of the information in a
    news item suitable for summary or preview.  html is 
    stripped and long fields are trimmed.
    """
    trace = Dibject()
    trace.timestamp = find_best_timestamp(e) or datetime.utcnow()

    trace.title = stripped_content(e.get('title_detail', None), 128)
    trace.author = trimmed(find_author_name(e), 128)
    trace.link = find_best_permalink(e)
    
    source = e.get('source', {})
    trace.source_url = find_source_url(source)
    trace.source_title = stripped_content(source.get('title_detail', None), 128)

    content = e.get('content', [None])[0]
    if content is None:
        content = e.get('summary_detail', None)
    trace.summary = stripped_content(content, 256)

    return trace