本文整理汇总了Python中output.Output.generate_header方法的典型用法代码示例。如果您正苦于以下问题:Python Output.generate_header方法的具体用法?Python Output.generate_header怎么用?Python Output.generate_header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类output.Output
的用法示例。
在下文中一共展示了Output.generate_header方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from output import Output [as 别名]
# 或者: from output.Output import generate_header [as 别名]
def main(send=False):
key = get_value('key')
html = None
# get movie info for all categories
for cat in CATEGORIES:
td = Tmdb(key, cat)
movies = td.get_movies(NUM_RES)
ca = Cache(os.path.basename(cat))
ca.shelve_results(movies)
newMovies = ca.shelve_results(movies)
movieObjects = ca.shelve_get_items(newMovies) # only new ones
op = Output(movieObjects)
if html is None:
html = [op.generate_header()]
catPrettified = cat.title().replace("_", " ")
html.append(op.generate_category_title(catPrettified))
html.append(op.generate_movie_html_div())
# save html
f = open(OUTFILE, "w")
f.write("\n".join(html))
f.close()
# email
if send:
subject = "Sharemovi.es / %s movies / week %s" % (", ".join(CATEGORIES), str(THIS_WEEK))
sender = get_value('sender')
recipients = load_emails('recipients')
ma = Mail(sender)
ma.mail_html(recipients, subject, "\n".join(html))
示例2: main
# 需要导入模块: from output import Output [as 别名]
# 或者: from output.Output import generate_header [as 别名]
def main():
(opts, args) = cli()
key = get_value('key')
td = Tmdb(key, opts.category)
if opts.listing:
li = Listing(opts.category)
movies = li.get_movies()
prefix = "list_"
subject = "Week %s: %s" % (THIS_WEEK, li.title)
else:
movies = td.get_movies(opts.numres)
prefix = ""
subject = "%s movies - week %s" % (opts.category.title().replace("_", " "), THIS_WEEK)
ca = Cache(prefix + os.path.basename(opts.category))
newMovies = ca.shelve_results(movies)
if opts.listing:
movieObjects = ca.shelve_get_items(movies) # allow dups
else:
movieObjects = ca.shelve_get_items(newMovies) # only new ones
op = Output(movieObjects)
html = [op.generate_header()]
html.append(op.generate_movie_html_div())
if opts.printres:
print "\n".join(html)
if opts.mailres:
sender = get_value('sender')
recipients = load_emails('recipients')
ma = Mail(sender)
ma.mail_html(recipients, subject, "\n".join(html))