本文整理汇总了Python中datafeeds.datafeed_fms_api.DatafeedFMSAPI.getAwards方法的典型用法代码示例。如果您正苦于以下问题:Python DatafeedFMSAPI.getAwards方法的具体用法?Python DatafeedFMSAPI.getAwards怎么用?Python DatafeedFMSAPI.getAwards使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datafeeds.datafeed_fms_api.DatafeedFMSAPI
的用法示例。
在下文中一共展示了DatafeedFMSAPI.getAwards方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from datafeeds.datafeed_fms_api import DatafeedFMSAPI [as 别名]
# 或者: from datafeeds.datafeed_fms_api.DatafeedFMSAPI import getAwards [as 别名]
def get(self, event_key):
datafeed = DatafeedFMSAPI('v2.0', save_response=True)
event = Event.get_by_id(event_key)
awards = datafeed.getAwards(event)
if event and event.remap_teams:
EventHelper.remapteams_awards(awards, event.remap_teams)
new_awards = AwardManipulator.createOrUpdate(awards)
if new_awards is None:
new_awards = []
elif type(new_awards) != list:
new_awards = [new_awards]
# create EventTeams
team_ids = set()
for award in new_awards:
for team in award.team_list:
team_ids.add(team.id())
teams = TeamManipulator.createOrUpdate([Team(
id=team_id,
team_number=int(team_id[3:]))
for team_id in team_ids])
if teams:
if type(teams) is not list:
teams = [teams]
event_teams = EventTeamManipulator.createOrUpdate([EventTeam(
id=event_key + "_" + team.key.id(),
event=event.key,
team=team.key,
year=event.year)
for team in teams])
template_values = {
'awards': new_awards,
}
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_awards_get.html')
self.response.out.write(template.render(path, template_values))
示例2: get
# 需要导入模块: from datafeeds.datafeed_fms_api import DatafeedFMSAPI [as 别名]
# 或者: from datafeeds.datafeed_fms_api.DatafeedFMSAPI import getAwards [as 别名]
def get(self, event_key):
datafeed = DatafeedFMSAPI('v2.0')
event = Event.get_by_id(event_key)
new_awards = AwardManipulator.createOrUpdate(datafeed.getAwards(event))
if new_awards is None:
new_awards = []
elif type(new_awards) != list:
new_awards = [new_awards]
# create EventTeams
team_ids = set()
for award in new_awards:
for team in award.team_list:
team_ids.add(team.id())
teams = TeamManipulator.createOrUpdate([Team(
id=team_id,
team_number=int(team_id[3:]))
for team_id in team_ids])
if teams:
if type(teams) is not list:
teams = [teams]
event_teams = EventTeamManipulator.createOrUpdate([EventTeam(
id=event_key + "_" + team.key.id(),
event=event.key,
team=team.key,
year=event.year)
for team in teams])
template_values = {
'awards': new_awards,
}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_awards_get.html')
self.response.out.write(template.render(path, template_values))