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


Python Game.all方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import all [as 别名]
    def get(self, name):
        if not users.get_current_user():
            self.redirect(users.create_login_url(self.request.uri))
        logging.info('Iniciando busca')
        results = search_metacritic(name, 'game')
        logging.info('Fetch concluido')
        output = []

        for result in results:
            query = Img.all()
            query.filter('url =', result[1])
            img = query.fetch(1)[0]
            query = Game.all()
            query.filter('cover =', img)
            if not query.count():
                platform = str(result[1])[:str(result[1]).rfind('/')].replace('/game/','')
                game = Game(name=str(result[0]),cover=img,platform=platform,score=str(result[2]))
                game.put()
            else:
                game = query.fetch(1)[0]
            output.append([img.key().id(), result[0], game.key().id()])

        template_values = {'results': output}

        path = os.path.join(os.path.dirname(__file__), 'search.html')
        self.response.out.write(template.render(path, template_values))
开发者ID:fabiomdiniz,项目名称:arcateca,代码行数:28,代码来源:views.py

示例2: games

# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import all [as 别名]
def games():
    gs = Game.all()
    games = {}
    for g in gs:
        game_id = str(g.key().id_or_name())
        games[game_id] = parse_game(g)
    return jsonify(**games)  # does not render a page, just returns a Json
开发者ID:keeeeenw,项目名称:AssassinServerAPI,代码行数:9,代码来源:views.py

示例3: handle_event

# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import all [as 别名]
def handle_event(event):
    home_team, away_team, date = find_event_info(event)
    game = Game.all()\
        .filter('home_team =', home_team)\
        .filter('away_team =', away_team)\
        .filter('start >=', date)\
        .get()

    if not game:
        return logging.error(
            'No game for %s @ %s @ %s' % (away_team, home_team, date))

    markets = event.find('markets').findall('market')
    points = None
    for market in markets:
        linetype = market.find('lineType')
        if linetype is not None and linetype.text.strip() == 'PSH':
            try:
                points = float(market.find('points').text)
            except ValueError:
                logging.error(
                    'Unknown points: %r' % market.find('points').text)
                points = None
            break
    game.spread = points
    logging.info('%s: %s' % (game, points))
    return game
开发者ID:mccutchen,项目名称:pickem,代码行数:29,代码来源:odds.py

示例4: get

# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import all [as 别名]
    def get(self):     
      # Can't provide an ordering here in case inequality filters are used.      
       base_query = Game.all()
       count = base_query.count()
       
       results = base_query.fetch(count)
       #db.delete(results)
   #    for game in results:
    #   	 		resultsobj = resultsobj + simplejson.dumps({"latitude":game.location.lat,"longitude":game.location.lon,"name":game.name,"type":game.game_type})
    #   objs = simplejson.dumps(resultsobj)
       
       public_attrs = Game.public_attributes()
      
       results_obj = [
          _merge_dicts({
            'lat': result.location.lat,
            'lng': result.location.lon,
            },
            dict([(attr, getattr(result, attr))
                  for attr in public_attrs]))
          for result in results]
		#for song in results:
    	#print song.type
  #     for result in query:
  # 				 resultsobj.push( "Title: " + result.address
       self.response.out.write(simplejson.dumps({
       'status': 'success',
       'count': count,
       'results': results_obj
     	}))
开发者ID:westinedu,项目名称:handsupmain,代码行数:32,代码来源:service.py

示例5: show_games

# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import all [as 别名]
def show_games():
    # Getting all the games
    gs = Game.all()

    # Build dictionary
    games = []
    for g in gs:
        games.append(to_dict(g))

    print(games)

    return render_template('show_games.html', games=games)  # first games is key, games is value
开发者ID:keeeeenw,项目名称:AssassinServerAPI,代码行数:14,代码来源:views.py

示例6: create_new_game

# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import all [as 别名]
def create_new_game():
    if Game.all().filter('title =', request.json['title']).count() == 0:
        name_of_player_to_join = list(set(request.json['players']))  # Makes sure each player is registered only once
        shuffle(name_of_player_to_join)
        players_to_join = [Player.all().filter('username =', name).get() for name in name_of_player_to_join]
        new_game = Game(title=request.json['title'], num_player=len(players_to_join))
        new_game.put()
        for i in range(-1, len(players_to_join)-1):
            killer = players_to_join[i]
            GamePlayer(game=new_game, player=killer).put()
            target = players_to_join[i+1]
            GameHistory(killer=killer, target=target, game=new_game, is_complete=False, confirm_msg=msg_generator()).put()
        return jsonify({"success": True})
    else:
        return jsonify({"success": False})
开发者ID:keeeeenw,项目名称:AssassinServerAPI,代码行数:17,代码来源:views.py

示例7: index

# 需要导入模块: from models import Game [as 别名]
# 或者: from models.Game import all [as 别名]
def index(request):
    games = Game.all().order('-created_at')
    return render_to_response('webigo/index.html', {'games':games})
开发者ID:michisu,项目名称:twitigo,代码行数:5,代码来源:views.py


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