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


Python Team.get_or_insert方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import get_or_insert [as 别名]
 def get(self, event_key):
     event = Event.get_by_key_name(event_key)
     teams = set()
     
     # Add teams from Matches
     for m in event.match_set:
         for team in m.team_key_names:
             teams.add(team)
     
     # Add teams from existing EventTeams
     for a in event.teams:
         if a.team:
             teams.add("frc%s" % a.team.team_number)
     
     eventteams_count = 0
     for team in teams:
         team_object = Team.get_or_insert(
             key_name = team,
             team_number = int(team[3:]), #"frc177"->"177"
             )
         
         et = EventTeam.get_or_insert(
             key_name = event_key + "_" + team,
             event = event,
             team = team_object,
             year = event.year)
         
         # Update if needed
         reput = False
         if not et.team:
             reput = True
             et.team = team_object
         elif et.team.key().name != team_object.key().name:
             reput = True
             et.team = team_object
         if et.year != event.year:
             reput = True
             et.year = event.year
         if reput:
             logging.info("Had to re-put %s" % et.key().name)
             et.put()
         
         eventteams_count = eventteams_count + 1
     
     template_values = {
         'eventteams_count': eventteams_count,
     }
     
     path = os.path.join(os.path.dirname(__file__), '../templates/cron/eventteam_update.html')
     self.response.out.write(template.render(path, template_values))
开发者ID:Apple101Review,项目名称:the-blue-alliance,代码行数:52,代码来源:cron_controller.py


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