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


Python Level.all方法代码示例

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


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

示例1: get

# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import all [as 别名]
  def get(self):
    players = {}
    levels = {}
    fetch = Level.all().fetch(100000)
    for l in fetch:
      levels[l.id] = l
      if not players.has_key(l.udid):
	players[l.udid] = Player()
      players[l.udid].uploaded.append(l)

    ratings = {}
    fetch = LevelStatistics.all().fetch(100000)
    for r in fetch:
      if not players.has_key(r.udid):
	players[r.udid] = Player()
      players[r.udid].ratings.append(r)

    self.w("players: %d<br>" % len(players))
    self.w("<table border=1>")
    for udid, p in players.items():
      self.w("<tr>")
      self.w("<td valign=top>%s</td>" % udid)
      self.w("<td valign=top>")
      for u in p.uploaded:
	self.response.out.write("%s" % u.name)
      self.w("</td>")
      self.w("<td valign=top>")
      for r in p.ratings:
	if levels.has_key(r.levelid):
	  self.response.out.write("%s" % levels[r.levelid].name)
	else:
	  self.response.out.write("<deleted>")
      self.w("</td>")
      self.w("</tr>")
    self.w("</table>")
开发者ID:wader,项目名称:slippy,代码行数:37,代码来源:stats.py

示例2: do

# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import all [as 别名]
  def do(self, limit):
    levels_query = Level.all(keys_only=True)

    if limit == "rated":
      levels_query.filter("rated =", True)
    elif limit == "new":
      one_month_ago = datetime.datetime.now() - datetime.timedelta(days=31)
      levels_query.filter("rated =", True)
      levels_query.filter("added >", one_month_ago)
    elif limit == "top":
      levels_query.filter("rated =", True)
      levels_query.order("-rating")

    levelkeys = levels_query.fetch(1000)
    levels = db.get(levelkeys)

    if self.format == "rss":
      last = datetime.datetime.now()
      if len(levels) > 0:
        last = levels[0].added

      def name(l):
	if l.author == "":
	  return l.name
	return l.name + " by " + l.author

      self.raw = True
      self.response.headers["Content-Type"] = "application/rss+xml"
      self.value = PyRSS2Gen.RSS2(
              title="Slippy recent levels",
              link="http://www.inwader.com/slippy/",
              description="Recently uploaded levels for Slippy the puzzel game",
              lastBuildDate=last,
              items=[
              PyRSS2Gen.RSSItem(
                      title=name(l),
                      link="http://www.inwader.com/slippy/",
                      description="",
                      guid=PyRSS2Gen.Guid(l.id, isPermaLink=False),
                      pubDate=l.added)
              for l in levels
              ]).to_xml(encoding="utf-8")
    else:
      self.value = {
        "version": 0,
        "levels": [l.dict() for l in levels]
      }
开发者ID:wader,项目名称:slippy,代码行数:49,代码来源:api.py

示例3: get

# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import all [as 别名]
  def get(self):
    while True:
      old = db.get(LevelStatistics.all(keys_only=True).filter("new =", False).fetch(1000))
      if len(old) == 0:
	break

      updated = []
      for o in old:
	o.new = True
	updated.append(o)
      db.put(updated)

    updated = []
    for l in db.get(Level.all(keys_only=True).fetch(1000)):
      l.ratings = 0
      l.ratingsum = 0
      updated.append(l)
    db.put(updated)
    logging.debug("reset ratings")
开发者ID:wader,项目名称:slippy,代码行数:21,代码来源:tasks.py


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