本文整理汇总了Python中datafeeds.datafeed_fms_api.DatafeedFMSAPI.getEventDetails方法的典型用法代码示例。如果您正苦于以下问题:Python DatafeedFMSAPI.getEventDetails方法的具体用法?Python DatafeedFMSAPI.getEventDetails怎么用?Python DatafeedFMSAPI.getEventDetails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datafeeds.datafeed_fms_api.DatafeedFMSAPI
的用法示例。
在下文中一共展示了DatafeedFMSAPI.getEventDetails方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from datafeeds.datafeed_fms_api import DatafeedFMSAPI [as 别名]
# 或者: from datafeeds.datafeed_fms_api.DatafeedFMSAPI import getEventDetails [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))