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


Python TeamManipulator.mergeModels方法代码示例

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


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

示例1: get

# 需要导入模块: from helpers.team_manipulator import TeamManipulator [as 别名]
# 或者: from helpers.team_manipulator.TeamManipulator import mergeModels [as 别名]
    def get(self, key_name):
        existing_team = Team.get_by_id(key_name)

        fms_df = DatafeedFMSAPI('v2.0')
        df2 = DatafeedFIRSTElasticSearch()
        year = datetime.date.today().year
        fms_details = fms_df.getTeamDetails(year, key_name)

        if fms_details:
            team, district_team, robot = fms_details[0]
        else:
            team = None
            district_team = None
            robot = None

        if team:
            team = TeamManipulator.mergeModels(team, df2.getTeamDetails(existing_team))
        else:
            team = df2.getTeamDetails(existing_team)

        if team:
            team = TeamManipulator.createOrUpdate(team)

        # Clean up junk district teams
        # https://www.facebook.com/groups/moardata/permalink/1310068625680096/
        dt_keys = DistrictTeam.query(
            DistrictTeam.team == existing_team.key,
            DistrictTeam.year == year).fetch(keys_only=True)
        keys_to_delete = set()
        for dt_key in dt_keys:
            if not district_team or dt_key.id() != district_team.key.id():
                keys_to_delete.add(dt_key)
        DistrictTeamManipulator.delete_keys(keys_to_delete)

        if district_team:
            district_team = DistrictTeamManipulator.createOrUpdate(district_team)

        if robot:
            robot = RobotManipulator.createOrUpdate(robot)

        template_values = {
            'key_name': key_name,
            'team': team,
            'success': team is not None,
            'district': district_team,
            'robot': robot,
        }

        if 'X-Appengine-Taskname' not in self.request.headers:  # Only write out if not in taskqueue
            path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_team_details_get.html')
            self.response.out.write(template.render(path, template_values))
开发者ID:,项目名称:,代码行数:53,代码来源:

示例2: get

# 需要导入模块: from helpers.team_manipulator import TeamManipulator [as 别名]
# 或者: from helpers.team_manipulator.TeamManipulator import mergeModels [as 别名]
    def get(self, key_name):
        existing_team = Team.get_by_id(key_name)

        fms_df = DatafeedFMSAPI('v2.0')
        df2 = DatafeedFIRSTElasticSearch()
        fms_details = fms_df.getTeamDetails(datetime.date.today().year, key_name)

        if fms_details:
            team, district_team, robot = fms_details[0]
        else:
            team = None
            district_team = None
            robot = None

        if team:
            team = TeamManipulator.mergeModels(team, df2.getTeamDetails(existing_team))
        else:
            team = df2.getTeamDetails(existing_team)

        if team:
            team = TeamManipulator.createOrUpdate(team)

        if district_team:
            district_team = DistrictTeamManipulator.createOrUpdate(district_team)

        if robot:
            robot = RobotManipulator.createOrUpdate(robot)

        template_values = {
            'key_name': key_name,
            'team': team,
            'success': team is not None,
            'district': district_team,
            'robot': robot,
        }

        if 'X-Appengine-Taskname' not in self.request.headers:  # Only write out if not in taskqueue
            path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_team_details_get.html')
            self.response.out.write(template.render(path, template_values))
开发者ID:dtbinh,项目名称:the-blue-alliance,代码行数:41,代码来源:datafeed_controller.py


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