本文整理汇总了Python中models.Team.all_teams方法的典型用法代码示例。如果您正苦于以下问题:Python Team.all_teams方法的具体用法?Python Team.all_teams怎么用?Python Team.all_teams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Team
的用法示例。
在下文中一共展示了Team.all_teams方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_odds
# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import all_teams [as 别名]
import datetime
import logging
import re
from xml.etree import ElementTree
from google.appengine.ext import db
from google.appengine.api import urlfetch
from models import Team, Game
feed_url = 'http://content.linesmaker.com/xml/lines/203.xml'
teams = Team.all_teams()
team_map = dict((team.name.lower(), team) for team in teams)
def update_odds():
logging.info('Fetching %s...' % feed_url)
resp = urlfetch.fetch(feed_url)
if not resp.status_code == 200:
return logging.error(
'Could not update odds. Bad response: %s' % resp.status_code)
logging.info('Parsing XML...')
try:
doc = ElementTree.fromstring(resp.content)
except Exception, e:
logging.error('Parse error: %s' % e)
logging.error('Contents:\n%s' % resp.content)
else:
events = doc.findall('event')
games = [handle_event(event) for event in events]