示例#1
0
文件: listings.py 项目: progo/moary
def entry_with_data(e):
    """Provide an entry `e' with extra data. Return a dict ready to be
    used in a format string.
    """

    title = with_color('Movie',e.movie)

    if not e.imdb:
        imdburl = ' '*36  # apprx length of a would-be IMDB url
    else:
        imdburl = imdbutils.imdb_url(e.imdb)

    # TODO: making this pretty message doubles the time to make a listing.
    if e.message:
        msglines = e.message.split('\n\n')
        msglines = [fill(line) for line in msglines]
        pretty_message = '\n' + '\n\n'.join(msglines)
    else:
        pretty_message = ''

    return EntryData(
        date=e.origdate.strftime("%Y-%m-%d"),
        longdate=e.origdate.strftime("%Y-%m-%d %H:%M"),
        rating=e.rating,
        message=e.message,
        message_formatted=pretty_message,
        graph=graph_func(e.rating),
        movie=title,
        title=title,
        imdburl=imdburl)
示例#2
0
文件: listings.py 项目: progo/moary
def format_org(e, args):
    """print entry e in an org-mode format."""
    LEVEL = 1 # what headline levels the movies make?
    result = [] # build the result string line-by-line
    result.append("*"*LEVEL + " " + e.movie)
    result.append(":PROPERTIES:")
    result.append(":RATING: " + str(e.rating))
    result.append(":IMDB: " + imdbutils.imdb_url(e.imdb))
    result.append(":END:")
    result.append(e.origdate.strftime("[%Y-%m-%d %a %H:%M]"))
    result.append(e.message)
    return '\n'.join(result)
示例#3
0
def format_full(e):
    """print entry e in a nice, full form."""
    formatstring = ('-'*78 + '\n'+
                    '{movie}\n'+
                    '{rating:<4} points       {imdburl}      ({longdate})'+
                    '{message}')
    if not e.imdb:
        imdburl = ' '*36  # apprx length of a would-be IMDB url
    else:
        imdburl = imdbutils.imdb_url(e.imdb)

    # massage messages to a nice form.
    if e.message:
        msglines = e.message.split('\n\n')
        msglines = [fill(line) for line in msglines]
        message = '\n' + '\n\n'.join(msglines)
    else:
        message = ''

    return formatstring.format(movie=with_color('Movie',e.movie),
            rating=e.rating,
            imdburl=imdburl,
            longdate=e.origdate.strftime("%Y-%m-%d %H:%M"),
            message=message)