本文整理汇总了Python中datafeeds.datafeed_usfirst.DatafeedUsfirst.getPre2003TeamEvents方法的典型用法代码示例。如果您正苦于以下问题:Python DatafeedUsfirst.getPre2003TeamEvents方法的具体用法?Python DatafeedUsfirst.getPre2003TeamEvents怎么用?Python DatafeedUsfirst.getPre2003TeamEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datafeeds.datafeed_usfirst.DatafeedUsfirst
的用法示例。
在下文中一共展示了DatafeedUsfirst.getPre2003TeamEvents方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from datafeeds.datafeed_usfirst import DatafeedUsfirst [as 别名]
# 或者: from datafeeds.datafeed_usfirst.DatafeedUsfirst import getPre2003TeamEvents [as 别名]
def get(self, key_name):
team_key = ndb.Key(Team, key_name)
df = DatafeedUsfirst()
first_eids = df.getPre2003TeamEvents(Team.get_by_id(key_name))
new_eids = []
for eid in first_eids:
event_keys = Event.query(Event.first_eid == eid).fetch(10, keys_only=True)
if len(event_keys) == 0: # only create events if event not already in db
try:
event = df.getEventDetails(eid)
except:
logging.warning("getEventDetails for eid {} failed.".format(eid))
continue
if event.event_type_enum in {EventType.CMP_DIVISION, EventType.CMP_FINALS}:
if event.year >= 2001:
# Divisions started in 2001; need to manually create championship events
continue
else:
# No divisions; force event type to be finals
event.event_type_enum = EventType.CMP_FINALS
event = EventManipulator.createOrUpdate(event)
new_eids.append(eid)
else:
event = event_keys[0].get()
event_team_key_name = event.key.id() + "_" + team_key.id()
existing_event_team = ndb.Key(EventTeam, event_team_key_name).get()
if existing_event_team is None:
event_team = EventTeam(
id=event_team_key_name,
event=event.key,
team=team_key,
year=event.year)
EventTeamManipulator.createOrUpdate(event_team)
template_values = {'first_eids': first_eids,
'new_eids': new_eids}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_team_events_get.html')
self.response.out.write(template.render(path, template_values))