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


Python EventDetailsManipulator.createOrUpdate方法代码示例

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


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

示例1: get

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
    def get(self, event_key):
        event = Event.get_by_id(event_key)
        if not event:
            self.abort(404)

        if not event.remap_teams:
            return

        event.prepAwardsMatchesTeams()

        # Remap matches
        EventHelper.remapteams_matches(event.matches, event.remap_teams)
        MatchManipulator.createOrUpdate(event.matches)

        # Remap alliance selections
        if event.alliance_selections:
            EventHelper.remapteams_alliances(event.alliance_selections, event.remap_teams)
        # Remap rankings
        if event.rankings:
            EventHelper.remapteams_rankings(event.rankings, event.remap_teams)
        if event.details and event.details.rankings2:
            EventHelper.remapteams_rankings2(event.details.rankings2, event.remap_teams)
        EventDetailsManipulator.createOrUpdate(event.details)

        # Remap awards
        EventHelper.remapteams_awards(event.awards, event.remap_teams)
        AwardManipulator.createOrUpdate(event.awards, auto_union=False)
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:29,代码来源:cron_controller.py

示例2: get

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
    def get(self, event_key):
        event = Event.get_by_id(event_key)
        matchstats_dict = MatchstatsHelper.calculate_matchstats(event.matches, event.year)
        if any([v != {} for v in matchstats_dict.values()]):
            pass
        else:
            logging.warn("Matchstat calculation for {} failed!".format(event_key))
            matchstats_dict = None

        predictions_dict = None
        if event.year == 2016:
            organized_matches = MatchHelper.organizeMatches(event.matches)
            match_predictions, match_prediction_stats = PredictionHelper.get_match_predictions(organized_matches['qm'])
            ranking_predictions, ranking_prediction_stats = PredictionHelper.get_ranking_predictions(organized_matches['qm'], match_predictions)

            predictions_dict = {
                'match_predictions': match_predictions,
                'match_prediction_stats': match_prediction_stats,
                'ranking_predictions': ranking_predictions,
                'ranking_prediction_stats': ranking_prediction_stats
            }

        event_details = EventDetails(
            id=event_key,
            matchstats=matchstats_dict,
            predictions=predictions_dict
        )
        EventDetailsManipulator.createOrUpdate(event_details)

        template_values = {
            'matchstats_dict': matchstats_dict,
        }

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

示例3: post

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
    def post(self, event_key_id):
        self._require_admin()
        event = Event.get_by_id(event_key_id)
        if not event:
            self.redirect("/admin/event/" + event.key_name)
            return
        event_details = event.details
        if not event_details or not event_details.alliance_selections:
            # No alliance data to modify
            self.redirect("/admin/event/" + event.key_name)
            return

        team_in = "frc{}".format(self.request.get("backup_in"))
        team_out = "frc{}".format(self.request.get("backup_out"))

        # Make sure both teams are attending the event
        et_in = EventTeam.get_by_id("{}_{}".format(event.key_name, team_in))
        et_out = EventTeam.get_by_id("{}_{}".format(event.key_name, team_out))
        if not et_in and et_out:
            # Bad teams supplied
            self.redirect("/admin/event/" + event.key_name)
            return

        for alliance in event_details.alliance_selections:
            if team_out in alliance.get('picks', []):
                alliance['backup'] = {}
                alliance['backup']['in'] = team_in
                alliance['backup']['out'] = team_out
                EventDetailsManipulator.createOrUpdate(event_details)
                break

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

示例4: create_event_details

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
def create_event_details(event_key):
  event = Event.get_by_id(event_key)
  if event.alliance_selections or event.district_points or event.matchstats or event.rankings:
    event_details = EventDetails(
      id=event_key,
      alliance_selections=event.alliance_selections,
      district_points=event.district_points,
      matchstats=event.matchstats,
      rankings=event.rankings)
    EventDetailsManipulator.createOrUpdate(event_details)
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:12,代码来源:admin_migration_controller.py

示例5: _process_request

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
    def _process_request(self, request, event_key):
        rankings = JSONRankingsParser.parse(request.body)

        event_details = EventDetails(
            id=event_key,
            rankings=rankings
        )
        if event_details.year >= 2017:  # TODO: Temporary fix. Should directly parse request into rankings2
            event_details.rankings2 = RankingsHelper.convert_rankings(event_details)
        EventDetailsManipulator.createOrUpdate(event_details)

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

示例6: _process_request

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
    def _process_request(self, request, event_key):
        rankings = JSONRankingsParser.parse(request.body)

        event = Event.get_by_id(event_key)

        event_details = EventDetails(
            id=event_key,
            rankings=rankings
        )
        EventDetailsManipulator.createOrUpdate(event_details)

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

示例7: _process_request

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
    def _process_request(self, request, event_key):
        alliance_selections = JSONAllianceSelectionsParser.parse(request.body)

        event_details = EventDetails(
            id=event_key,
            alliance_selections=alliance_selections
        )

        if self.event.remap_teams:
            EventHelper.remapteams_alliances(event_details.alliance_selections, self.event.remap_teams)
        EventDetailsManipulator.createOrUpdate(event_details)

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

示例8: post

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
    def post(self, event_key):
        self._require_admin()

        # Note, we don't actually use event_key.

        start_date = None
        if self.request.get("start_date"):
            start_date = datetime.strptime(self.request.get("start_date"), "%Y-%m-%d")

        end_date = None
        if self.request.get("end_date"):
            end_date = datetime.strptime(self.request.get("end_date"), "%Y-%m-%d")

        district_key = self.request.get("event_district_key", None)

        event = Event(
            id=str(self.request.get("year")) + str.lower(str(self.request.get("event_short"))),
            end_date=end_date,
            event_short=self.request.get("event_short"),
            event_type_enum=EventHelper.parseEventType(self.request.get("event_type_str")),
            district_key=ndb.Key(District, self.request.get("event_district_key")) if district_key and district_key != 'None' else None,
            venue=self.request.get("venue"),
            venue_address=self.request.get("venue_address"),
            city=self.request.get("city"),
            state_prov=self.request.get("state_prov"),
            postalcode=self.request.get("postalcode"),
            country=self.request.get("country"),
            name=self.request.get("name"),
            short_name=self.request.get("short_name"),
            start_date=start_date,
            website=self.request.get("website"),
            year=int(self.request.get("year")),
            official={"true": True, "false": False}.get(self.request.get("official").lower()),
            facebook_eid=self.request.get("facebook_eid"),
            custom_hashtag=self.request.get("custom_hashtag"),
            webcast_json=self.request.get("webcast_json"),
            playoff_type=int(self.request.get("playoff_type")),
        )
        event = EventManipulator.createOrUpdate(event)

        if self.request.get("alliance_selections_json") or self.request.get("rankings_json"):
            event_details = EventDetails(
                id=event_key,
                alliance_selections=json.loads(self.request.get("alliance_selections_json")),
                rankings=json.loads(self.request.get("rankings_json"))
            )
            EventDetailsManipulator.createOrUpdate(event_details)

        MemcacheWebcastFlusher.flushEvent(event.key_name)

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

示例9: get

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
  def get(self, year):
    self._require_admin()

    event_keys = Event.query(Event.year==int(year)).fetch(keys_only=True)
    event_details = ndb.get_multi([ndb.Key(EventDetails, key.id()) for key in event_keys])
    updated = []
    for event_detail in event_details:
      if event_detail:
        logging.info(event_detail.key.id())
        event_detail.rankings2 = RankingsHelper.convert_rankings(event_detail)
        updated.append(event_detail)
    EventDetailsManipulator.createOrUpdate(updated)

    self.response.out.write("DONE")
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:16,代码来源:admin_migration_controller.py

示例10: _update_rankings

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
    def _update_rankings(self):
        """
        Generates and saves fake rankings
        """
        event = Event.get_by_id('2016nytr')

        team_wins = defaultdict(int)
        team_losses = defaultdict(int)
        team_ties = defaultdict(int)
        teams = set()
        for match in event.matches:
            if match.comp_level == 'qm':
                for alliance in ['red', 'blue']:
                    for team in match.alliances[alliance]['teams']:
                        teams.add(team)
                        if match.has_been_played:
                            if alliance == match.winning_alliance:
                                team_wins[team] += 1
                            elif match.winning_alliance == '':
                                team_ties[team] += 1
                            else:
                                team_losses[team] += 1

        rankings = []
        for team in sorted(teams):
            wins = team_wins[team]
            losses = team_losses[team]
            ties = team_ties[team]
            rankings.append({
                'team_key': team,
                'record': {
                    'wins': wins,
                    'losses': losses,
                    'ties': ties,
                },
                'matches_played': wins + losses + ties,
                'dq': 0,
                'sort_orders': [2 * wins + ties, 0, 0, 0, 0],
                'qual_average': None,
            })
        rankings = sorted(rankings, key=lambda r: -r['sort_orders'][0])

        for i, ranking in enumerate(rankings):
            ranking['rank'] = i + 1

        EventDetailsManipulator.createOrUpdate(EventDetails(
            id='2016nytr',
            rankings2=rankings,
        ))
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:51,代码来源:event_simulator.py

示例11: get

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
    def get(self, event_key):
        df = DatafeedFMSAPI('v2.0', save_response=True)

        event = Event.get_by_id(event_key)

        alliance_selections = df.getEventAlliances(event_key)

        event_details = EventDetails(
            id=event_key,
            alliance_selections=alliance_selections
        )
        EventDetailsManipulator.createOrUpdate(event_details)

        template_values = {'alliance_selections': alliance_selections,
                           'event_name': event_details.key.id()}

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

示例12: test_createOrUpdate

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
 def test_createOrUpdate(self):
     EventDetailsManipulator.createOrUpdate(self.old_event_details)
     self.assertOldEventDetails(EventDetails.get_by_id('2011ct'))
     EventDetailsManipulator.createOrUpdate(self.new_event_details)
     self.assertMergedEventDetails(EventDetails.get_by_id('2011ct'))
开发者ID:CarterFendley,项目名称:the-blue-alliance,代码行数:7,代码来源:test_event_details_manipulator.py

示例13: step

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
    def step(self):
        event = Event.get_by_id('2016nytr')

        if self._step == 0:  # Qual match schedule added
            for match in copy.deepcopy(self._all_matches['qm']):
                for alliance in ['red', 'blue']:
                    match.alliances[alliance]['score'] = -1
                match.alliances_json = json.dumps(match.alliances)
                match.score_breakdown_json = None
                match.actual_time = None
                MatchManipulator.createOrUpdate(match)

            self._step += 1
        elif self._step == 1:  # After each qual match
            MatchManipulator.createOrUpdate(self._played_matches['qm'][self._substep])
            if self._substep < len(self._played_matches['qm']) - 1:
                self._substep += 1
            else:
                self._step += 1
                self._substep = 0
            EventDetailsManipulator.createOrUpdate(EventDetails(id='2016nytr'))
        elif self._step == 2:  # After alliance selections
            EventDetailsManipulator.createOrUpdate(EventDetails(
                id='2016nytr',
                alliance_selections=self._alliance_selections_without_backup
            ))
            self._step += 1
        elif self._step == 3:  # QF schedule added
            for match in copy.deepcopy(self._all_matches['qf']):
                for alliance in ['red', 'blue']:
                    match.alliances[alliance]['score'] = -1
                match.alliances_json = json.dumps(match.alliances)
                match.score_breakdown_json = None
                match.actual_time = None
                MatchManipulator.createOrUpdate(match)
            self._step += 1
        elif self._step == 4:  # After each QF match
            new_match = MatchHelper.play_order_sort_matches(self._played_matches['qf'])[self._substep]
            MatchManipulator.createOrUpdate(new_match)

            if not self._batch_advance:
                win_counts = {
                    'red': 0,
                    'blue': 0,
                }
                for i in xrange(new_match.match_number):
                    win_counts[Match.get_by_id(
                        Match.renderKeyName(
                            new_match.event.id(),
                            new_match.comp_level,
                            new_match.set_number,
                            i+1)).winning_alliance] += 1
                for alliance, wins in win_counts.items():
                    if wins == 2:
                        s = new_match.set_number
                        if s in {1, 2}:
                            self._advancement_alliances['sf1']['red' if s == 1 else 'blue'] = new_match.alliances[alliance]['teams']
                        elif s in {3, 4}:
                            self._advancement_alliances['sf2']['red' if s == 3 else 'blue'] = new_match.alliances[alliance]['teams']
                        else:
                            raise Exception("Invalid set number: {}".format(s))

                        for match_set, alliances in self._advancement_alliances.items():
                            if match_set.startswith('sf'):
                                for i in xrange(3):
                                    for match in copy.deepcopy(self._all_matches['sf']):
                                        key = '2016nytr_{}m{}'.format(match_set, i+1)
                                        if match.key.id() == key:
                                            for color in ['red', 'blue']:
                                                match.alliances[color]['score'] = -1
                                                match.alliances[color]['teams'] = alliances.get(color, [])
                                            match.alliances_json = json.dumps(match.alliances)
                                            match.score_breakdown_json = None
                                            match.actual_time = None
                                            MatchManipulator.createOrUpdate(match)

            if self._substep < len(self._played_matches['qf']) - 1:
                self._substep += 1
            else:
                self._step += 1 if self._batch_advance else 2
                self._substep = 0
        elif self._step == 5:  # SF schedule added
            if self._batch_advance:
                for match in copy.deepcopy(self._all_matches['sf']):
                    for alliance in ['red', 'blue']:
                        match.alliances[alliance]['score'] = -1
                    match.alliances_json = json.dumps(match.alliances)
                    match.score_breakdown_json = None
                    match.actual_time = None
                    MatchManipulator.createOrUpdate(match)
                self._step += 1
        elif self._step == 6:  # After each SF match
            new_match = MatchHelper.play_order_sort_matches(self._played_matches['sf'])[self._substep]
            MatchManipulator.createOrUpdate(new_match)

            if not self._batch_advance:
                win_counts = {
                    'red': 0,
                    'blue': 0,
                }
#.........这里部分代码省略.........
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:103,代码来源:event_simulator.py

示例14: post

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
    def post(self, event_key):
        self._require_admin()

        # Note, we don't actually use event_key.

        start_date = None
        if self.request.get("start_date"):
            start_date = datetime.strptime(self.request.get("start_date"), "%Y-%m-%d")

        end_date = None
        if self.request.get("end_date"):
            end_date = datetime.strptime(self.request.get("end_date"), "%Y-%m-%d")

        first_code = self.request.get("first_code", None)
        district_key = self.request.get("event_district_key", None)
        parent_key = self.request.get("parent_event", None)

        division_key_names = json.loads(self.request.get('divisions'), '[]') if self.request.get('divisions') else []
        division_keys = [ndb.Key(Event, key) for key in division_key_names] if division_key_names else []

        website = WebsiteHelper.format_url(self.request.get("website"))

        event = Event(
            id=str(self.request.get("year")) + str.lower(str(self.request.get("event_short"))),
            end_date=end_date,
            event_short=self.request.get("event_short"),
            first_code=first_code if first_code and first_code != 'None' else None,
            event_type_enum=int(self.request.get("event_type")) if self.request.get('event_type') else EventType.UNLABLED,
            district_key=ndb.Key(District, self.request.get("event_district_key")) if district_key and district_key != 'None' else None,
            venue=self.request.get("venue"),
            venue_address=self.request.get("venue_address"),
            city=self.request.get("city"),
            state_prov=self.request.get("state_prov"),
            postalcode=self.request.get("postalcode"),
            country=self.request.get("country"),
            name=self.request.get("name"),
            short_name=self.request.get("short_name"),
            start_date=start_date,
            website=website,
            year=int(self.request.get("year")),
            official={"true": True, "false": False}.get(self.request.get("official").lower()),
            enable_predictions={"true": True, "false": False}.get(self.request.get("enable_predictions").lower()),
            facebook_eid=self.request.get("facebook_eid"),
            custom_hashtag=self.request.get("custom_hashtag"),
            webcast_json=self.request.get("webcast_json"),
            playoff_type=int(self.request.get("playoff_type")) if self.request.get('playoff_type') else PlayoffType.BRACKET_8_TEAM,
            parent_event=ndb.Key(Event, parent_key) if parent_key and parent_key.lower() != 'none' else None,
            divisions=division_keys,
        )
        event = EventManipulator.createOrUpdate(event)

        if self.request.get("alliance_selections_json") or self.request.get("rankings_json"):
            event_details = EventDetails(
                id=event_key,
                alliance_selections=json.loads(self.request.get("alliance_selections_json")),
                rankings=json.loads(self.request.get("rankings_json"))
            )
            EventDetailsManipulator.createOrUpdate(event_details)

        MemcacheWebcastFlusher.flushEvent(event.key_name)

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

示例15: get

# 需要导入模块: from helpers.event_details_manipulator import EventDetailsManipulator [as 别名]
# 或者: from helpers.event_details_manipulator.EventDetailsManipulator import createOrUpdate [as 别名]
    def get(self, event_key):
        if tba_config.CONFIG["env"] == "prod":  # disable in prod for now
            logging.error("Tried to restore {} from CSV in prod! No can do.".format(event_key))
            return

        event = Event.get_by_id(event_key)

        # alliances
        result = urlfetch.fetch(self.ALLIANCES_URL.format(event.year, event_key, event_key))
        if result.status_code != 200:
            logging.warning('Unable to retreive url: ' + (self.ALLIANCES_URL.format(event.year, event_key, event_key)))
        else:
            data = result.content.replace('frc', '')
            alliance_selections = CSVAllianceSelectionsParser.parse(data)

            event_details = EventDetails(
                id=event_key,
                alliance_selections=alliance_selections
            )
            EventDetailsManipulator.createOrUpdate(event_details)

        # awards
        result = urlfetch.fetch(self.AWARDS_URL.format(event.year, event_key, event_key))
        if result.status_code != 200:
            logging.warning('Unable to retreive url: ' + (self.AWARDS_URL.format(event.year, event_key, event_key)))
        else:
            # convert into expected input format
            data = StringIO.StringIO()
            writer = csv.writer(data, delimiter=',')
            for row in csv.reader(StringIO.StringIO(result.content), delimiter=','):
                writer.writerow([event.year, event.event_short, row[1], row[2].replace('frc', ''), row[3]])

            awards = []
            for award in CSVAwardsParser.parse(data.getvalue()):
                awards.append(Award(
                    id=Award.render_key_name(event.key_name, award['award_type_enum']),
                    name_str=award['name_str'],
                    award_type_enum=award['award_type_enum'],
                    year=event.year,
                    event=event.key,
                    event_type_enum=event.event_type_enum,
                    team_list=[ndb.Key(Team, 'frc{}'.format(team_number)) for team_number in award['team_number_list']],
                    recipient_json_list=award['recipient_json_list']
                ))
            AwardManipulator.createOrUpdate(awards)

        # matches
        result = urlfetch.fetch(self.MATCHES_URL.format(event.year, event_key, event_key))
        if result.status_code != 200:
            logging.warning('Unable to retreive url: ' + (self.MATCHES_URL.format(event.year, event_key, event_key)))
        else:
            data = result.content.replace('frc', '').replace('{}_'.format(event_key), '')
            match_dicts, _ = OffseasonMatchesParser.parse(data)
            matches = [
                Match(
                    id=Match.renderKeyName(
                        event.key.id(),
                        match.get("comp_level", None),
                        match.get("set_number", 0),
                        match.get("match_number", 0)),
                    event=event.key,
                    year=event.year,
                    set_number=match.get("set_number", 0),
                    match_number=match.get("match_number", 0),
                    comp_level=match.get("comp_level", None),
                    team_key_names=match.get("team_key_names", None),
                    alliances_json=match.get("alliances_json", None)
                )
            for match in match_dicts]
            MatchManipulator.createOrUpdate(matches)

        # rankings
        result = urlfetch.fetch(self.RANKINGS_URL.format(event.year, event_key, event_key))
        if result.status_code != 200:
            logging.warning('Unable to retreive url: ' + (self.RANKINGS_URL.format(event.year, event_key, event_key)))
        else:
            # convert into expected input format
            rankings = list(csv.reader(StringIO.StringIO(result.content), delimiter=','))

            event_details = EventDetails(
                id=event_key,
                rankings=rankings
            )
            EventDetailsManipulator.createOrUpdate(event_details)

        self.response.out.write("Done restoring {}!".format(event_key))
开发者ID:MC42,项目名称:the-blue-alliance,代码行数:88,代码来源:backup_controller.py


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