当前位置: 首页>>代码示例>>Python>>正文


Python Cache.shelve_results方法代码示例

本文整理汇总了Python中cache.Cache.shelve_results方法的典型用法代码示例。如果您正苦于以下问题:Python Cache.shelve_results方法的具体用法?Python Cache.shelve_results怎么用?Python Cache.shelve_results使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cache.Cache的用法示例。


在下文中一共展示了Cache.shelve_results方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from cache import Cache [as 别名]
# 或者: from cache.Cache import shelve_results [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))
开发者ID:bbelderbos,项目名称:themoviedb,代码行数:30,代码来源:weekly.py

示例2: main

# 需要导入模块: from cache import Cache [as 别名]
# 或者: from cache.Cache import shelve_results [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))
开发者ID:bbelderbos,项目名称:themoviedb,代码行数:31,代码来源:main.py


注:本文中的cache.Cache.shelve_results方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。