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


Python EventTeamManipulator.delete_keys方法代码示例

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


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

示例1: get

# 需要导入模块: from helpers.event_team_manipulator import EventTeamManipulator [as 别名]
# 或者: from helpers.event_team_manipulator.EventTeamManipulator import delete_keys [as 别名]
    def get(self, event_key):
        self._require_admin()
        event = Event.get_by_id(event_key)
        if not event:
            self.abort(404)
            return
        existing_event_team_keys = set(EventTeam.query(EventTeam.event == event.key).fetch(1000, keys_only=True))
        EventTeamManipulator.delete_keys(existing_event_team_keys)

        self.response.out.write("Deleted {} EventTeams from {}".format(len(existing_event_team_keys), event_key))
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:12,代码来源:admin_cron_controller.py

示例2: get

# 需要导入模块: from helpers.event_team_manipulator import EventTeamManipulator [as 别名]
# 或者: from helpers.event_team_manipulator.EventTeamManipulator import delete_keys [as 别名]
    def get(self, year, first_eid):
        df = DatafeedUsfirst()
        df_legacy = DatafeedUsfirstLegacy()

        event = df.getEventDetails(first_eid)
        if not event:
            logging.warning("getEventDetails with DatafeedUsfirst for event id {} failed. Retrying with DatafeedUsfirstLegacy.".format(first_eid))
            event = df_legacy.getEventDetails(int(year), first_eid)

        if self.request.get('event_district_enum'):
            event.event_district_enum = int(self.request.get('event_district_enum'))
        event = EventManipulator.createOrUpdate(event)

        teams = df.getEventTeams(int(year), first_eid)
        if not teams:
            logging.warning("getEventTeams with DatafeedUsfirst for event id {} failed. Retrying with DatafeedUsfirstLegacy.".format(first_eid))
            teams = df_legacy.getEventTeams(int(year), first_eid)
            if not teams:
                logging.warning("getEventTeams with DatafeedUsfirstLegacy for event id {} failed.".format(first_eid))
                teams = []

        teams = TeamManipulator.createOrUpdate(teams)

        if teams:
            if type(teams) is not list:
                teams = [teams]

            event_teams = [EventTeam(
                id=event.key.id() + "_" + team.key.id(),
                event=event.key,
                team=team.key,
                year=event.year)
                for team in teams]

            # Delete eventteams of teams that unregister from an event
            if event.future:
                existing_event_team_keys = set(EventTeam.query(EventTeam.event == event.key).fetch(1000, keys_only=True))
                event_team_keys = set([et.key for et in event_teams])
                et_keys_to_delete = existing_event_team_keys.difference(event_team_keys)
                EventTeamManipulator.delete_keys(et_keys_to_delete)

            event_teams = EventTeamManipulator.createOrUpdate(event_teams)
            if type(event_teams) is not list:
                event_teams = [event_teams]
        else:
            event_teams = []

        template_values = {
            'event': event,
            'event_teams': event_teams,
        }

        path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_event_details_get.html')
        self.response.out.write(template.render(path, template_values))
开发者ID:dewdn2,项目名称:the-blue-alliance,代码行数:56,代码来源:datafeed_controller.py

示例3: get

# 需要导入模块: from helpers.event_team_manipulator import EventTeamManipulator [as 别名]
# 或者: from helpers.event_team_manipulator.EventTeamManipulator import delete_keys [as 别名]
    def get(self, event_key):
        df = DatafeedFMSAPI('v2.0')
        event = Event.get_by_id(event_key)

        models = df.getEventTeams(event_key)
        teams = []
        district_teams = []
        robots = []
        for group in models:
            # models is a list of tuples (team, districtTeam, robot)
            if isinstance(group[0], Team):
                teams.append(group[0])
            if isinstance(group[1], DistrictTeam):
                district_teams.append(group[1])
            if isinstance(group[2], Robot):
                robots.append(group[2])

        # Write new models
        teams = TeamManipulator.createOrUpdate(teams)
        district_teams = DistrictTeamManipulator.createOrUpdate(district_teams)
        robots = RobotManipulator.createOrUpdate(robots)

        if not teams:
            # No teams found registered for this event
            teams = []

        # Build EventTeams
        event_teams = [EventTeam(
            id=event.key_name + "_" + team.key_name,
            event=event.key,
            team=team.key,
            year=event.year)
            for team in teams]

        # Delete eventteams of teams that are no longer registered
        if event.future:
            existing_event_team_keys = set(EventTeam.query(EventTeam.event == event.key).fetch(1000, keys_only=True))
            event_team_keys = set([et.key for et in event_teams])
            et_keys_to_delete = existing_event_team_keys.difference(event_team_keys)
            EventTeamManipulator.delete_keys(et_keys_to_delete)

        event_teams = EventTeamManipulator.createOrUpdate(event_teams)
        if type(event_teams) is not list:
            event_teams = [event_teams]

        template_values = {
            'event': event,
            'event_teams': event_teams,
        }

        path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_event_details_get.html')
        self.response.out.write(template.render(path, template_values))
开发者ID:arilotter,项目名称:the-blue-alliance,代码行数:54,代码来源:datafeed_controller.py

示例4: post

# 需要导入模块: from helpers.event_team_manipulator import EventTeamManipulator [as 别名]
# 或者: from helpers.event_team_manipulator.EventTeamManipulator import delete_keys [as 别名]
    def post(self, event_key_id):
        self._require_admin()
        event = Event.get_by_id(event_key_id)

        teams_csv = self.request.get('teams_csv')
        team_numbers = CSVTeamsParser.parse(teams_csv)

        event_teams = []
        for team_number in team_numbers:
            event_teams.append(ndb.Key(EventTeam, '{}_frc{}'.format(event.key.id(), team_number)))

        EventTeamManipulator.delete_keys(event_teams)

        self.redirect("/admin/event/" + event.key_name)
开发者ID:technonerdz,项目名称:the-blue-alliance,代码行数:16,代码来源:admin_event_controller.py

示例5: get

# 需要导入模块: from helpers.event_team_manipulator import EventTeamManipulator [as 别名]
# 或者: from helpers.event_team_manipulator.EventTeamManipulator import delete_keys [as 别名]
    def get(self, event_key):
        teams, event_teams, et_keys_to_del = EventTeamUpdater.update(event_key)

        teams = TeamManipulator.createOrUpdate(teams)

        if teams:
            event_teams = EventTeamManipulator.createOrUpdate(event_teams)

        if et_keys_to_del:
            EventTeamManipulator.delete_keys(et_keys_to_del)

        template_values = {"event_teams": event_teams, "deleted_event_teams_keys": et_keys_to_del}

        path = os.path.join(os.path.dirname(__file__), "../templates/math/eventteam_update_do.html")
        self.response.out.write(template.render(path, template_values))
开发者ID:brandondean,项目名称:the-blue-alliance,代码行数:17,代码来源:cron_controller.py

示例6: _process_request

# 需要导入模块: from helpers.event_team_manipulator import EventTeamManipulator [as 别名]
# 或者: from helpers.event_team_manipulator.EventTeamManipulator import delete_keys [as 别名]
    def _process_request(self, request, event_key):
        team_keys = JSONTeamListParser.parse(request.body)
        event = Event.get_by_id(event_key)

        event_teams = []
        for team_key in team_keys:
            event_teams.append(EventTeam(id=event.key.id() + '_{}'.format(team_key),
                                         event=event.key,
                                         team=ndb.Key(Team, team_key),
                                         year=event.year))

        # delete old eventteams
        old_eventteam_keys = EventTeam.query(EventTeam.event == event.key).fetch(None, keys_only=True)
        to_delete = set(old_eventteam_keys).difference(set([et.key for et in event_teams]))
        EventTeamManipulator.delete_keys(to_delete)

        EventTeamManipulator.createOrUpdate(event_teams)
开发者ID:dewdn2,项目名称:the-blue-alliance,代码行数:19,代码来源:api_trusted_controller.py

示例7: get

# 需要导入模块: from helpers.event_team_manipulator import EventTeamManipulator [as 别名]
# 或者: from helpers.event_team_manipulator.EventTeamManipulator import delete_keys [as 别名]
    def get(self, event_key):
        _, event_teams, et_keys_to_del = EventTeamUpdater.update(event_key)

        if event_teams:
            event_teams = filter(lambda et: et.team.get() is not None, event_teams)
            event_teams = EventTeamManipulator.createOrUpdate(event_teams)

        if et_keys_to_del:
            EventTeamManipulator.delete_keys(et_keys_to_del)

        template_values = {
            'event_teams': event_teams,
            'deleted_event_teams_keys': et_keys_to_del
        }

        path = os.path.join(os.path.dirname(__file__),
                            '../templates/math/eventteam_update_do.html')
        self.response.out.write(template.render(path, template_values))
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:20,代码来源:cron_controller.py

示例8: _process_request

# 需要导入模块: from helpers.event_team_manipulator import EventTeamManipulator [as 别名]
# 或者: from helpers.event_team_manipulator.EventTeamManipulator import delete_keys [as 别名]
    def _process_request(self, request, event_key):
        team_keys = JSONTeamListParser.parse(request.body)

        event_teams = []
        for team_key in team_keys:
            if Team.get_by_id(team_key):  # Don't create EventTeams for teams that don't exist
                event_teams.append(EventTeam(id=self.event.key.id() + '_{}'.format(team_key),
                                             event=self.event.key,
                                             team=ndb.Key(Team, team_key),
                                             year=self.event.year))

        # delete old eventteams
        old_eventteam_keys = EventTeam.query(EventTeam.event == self.event.key).fetch(None, keys_only=True)
        to_delete = set(old_eventteam_keys).difference(set([et.key for et in event_teams]))
        EventTeamManipulator.delete_keys(to_delete)

        EventTeamManipulator.createOrUpdate(event_teams)

        self.response.out.write(json.dumps({'Success': "Event teams successfully updated"}))
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:21,代码来源:api_trusted_controller.py

示例9: get

# 需要导入模块: from helpers.event_team_manipulator import EventTeamManipulator [as 别名]
# 或者: from helpers.event_team_manipulator.EventTeamManipulator import delete_keys [as 别名]
    def get(self, event_key):
        df = DatafeedFMSAPI('v2.0')
        df2 = DatafeedFIRSTElasticSearch()

        event = Event.get_by_id(event_key)

        # Update event
        fmsapi_events, fmsapi_districts = df.getEventDetails(event_key)
        elasticsearch_events = df2.getEventDetails(event)
        updated_event = EventManipulator.mergeModels(
            fmsapi_events,
            elasticsearch_events)
        if updated_event:
            event = EventManipulator.createOrUpdate(updated_event)
        DistrictManipulator.createOrUpdate(fmsapi_districts)

        models = df.getEventTeams(event_key)
        teams = []
        district_teams = []
        robots = []
        for group in models:
            # models is a list of tuples (team, districtTeam, robot)
            if isinstance(group[0], Team):
                teams.append(group[0])
            if isinstance(group[1], DistrictTeam):
                district_teams.append(group[1])
            if isinstance(group[2], Robot):
                robots.append(group[2])

        # Merge teams
        teams = TeamManipulator.mergeModels(teams, df2.getEventTeams(event))

        # Write new models
        if teams:
            teams = TeamManipulator.createOrUpdate(teams)
        district_teams = DistrictTeamManipulator.createOrUpdate(district_teams)
        robots = RobotManipulator.createOrUpdate(robots)

        if not teams:
            # No teams found registered for this event
            teams = []
        if type(teams) is not list:
            teams = [teams]

        # Build EventTeams
        cmp_hack_sitevar = Sitevar.get_or_insert('cmp_registration_hacks')
        events_without_eventteams = cmp_hack_sitevar.contents.get('skip_eventteams', []) \
            if cmp_hack_sitevar else []
        skip_eventteams = event_key in events_without_eventteams
        event_teams = [EventTeam(
            id=event.key_name + "_" + team.key_name,
            event=event.key,
            team=team.key,
            year=event.year)
            for team in teams] if not skip_eventteams else []

        # Delete eventteams of teams that are no longer registered
        if event_teams != [] or skip_eventteams:
            existing_event_team_keys = set(EventTeam.query(EventTeam.event == event.key).fetch(1000, keys_only=True))
            event_team_keys = set([et.key for et in event_teams])
            et_keys_to_delete = existing_event_team_keys.difference(event_team_keys)
            EventTeamManipulator.delete_keys(et_keys_to_delete)

            event_teams = EventTeamManipulator.createOrUpdate(event_teams)
        if type(event_teams) is not list:
            event_teams = [event_teams]

        template_values = {
            'event': event,
            'event_teams': event_teams,
        }

        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_event_details_get.html')
            self.response.out.write(template.render(path, template_values))
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:77,代码来源:datafeed_controller.py


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