本文整理汇总了Python中datafeeds.datafeed_usfirst.DatafeedUsfirst.getMatches方法的典型用法代码示例。如果您正苦于以下问题:Python DatafeedUsfirst.getMatches方法的具体用法?Python DatafeedUsfirst.getMatches怎么用?Python DatafeedUsfirst.getMatches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datafeeds.datafeed_usfirst.DatafeedUsfirst
的用法示例。
在下文中一共展示了DatafeedUsfirst.getMatches方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from datafeeds.datafeed_usfirst import DatafeedUsfirst [as 别名]
# 或者: from datafeeds.datafeed_usfirst.DatafeedUsfirst import getMatches [as 别名]
def get(self, event_key):
df = DatafeedUsfirst()
event = Event.get_by_id(event_key)
new_matches = MatchManipulator.createOrUpdate(df.getMatches(event))
if new_matches:
for match in new_matches:
if hasattr(match, 'dirty') and match.dirty:
# Enqueue push notification
try:
FirebasePusher.updated_event(event.key_name)
except:
logging.warning("Enqueuing Firebase push failed!")
# Enqueue task to calculate matchstats
taskqueue.add(
url='/tasks/math/do/event_matchstats/' + event.key_name,
method='GET')
break
template_values = {
'matches': new_matches,
}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_matches_get.html')
self.response.out.write(template.render(path, template_values))
示例2: get
# 需要导入模块: from datafeeds.datafeed_usfirst import DatafeedUsfirst [as 别名]
# 或者: from datafeeds.datafeed_usfirst.DatafeedUsfirst import getMatches [as 别名]
def get(self, event_key):
df = DatafeedUsfirst()
event = Event.get_by_id(event_key)
new_matches = MatchManipulator.createOrUpdate(df.getMatches(event))
template_values = {
'matches': new_matches,
}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_matches_get.html')
self.response.out.write(template.render(path, template_values))
示例3: TestDatafeedUsfirstMatches
# 需要导入模块: from datafeeds.datafeed_usfirst import DatafeedUsfirst [as 别名]
# 或者: from datafeeds.datafeed_usfirst.DatafeedUsfirst import getMatches [as 别名]
class TestDatafeedUsfirstMatches(unittest2.TestCase):
def setUp(self):
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_urlfetch_stub()
self.testbed.init_datastore_v3_stub()
self.testbed.init_memcache_stub()
self.datafeed = DatafeedUsfirst()
def tearDown(self):
self.testbed.deactivate()
def test_getMatchResultsList(self):
event = Event(
id = "2011ct",
event_short = "ct",
year = 2011
)
matches = self.datafeed.getMatches(event)
# Test 2011ct_qm1
match = matches[0]
self.assertEqual(match.comp_level, "qm")
self.assertEqual(match.set_number, 1)
self.assertEqual(match.match_number, 1)
self.assertEqual(match.team_key_names, [u'frc69', u'frc571', u'frc176', u'frc3464', u'frc20', u'frc1073'])
self.assertEqual(match.alliances_json, """{"blue": {"score": 57, "teams": ["frc3464", "frc20", "frc1073"]}, "red": {"score": 74, "teams": ["frc69", "frc571", "frc176"]}}""")
self.assertEqual(match.time_string, "9:29 AM")
# Test 2011ct_qf2m3
match = matches[-7]
self.assertEqual(match.comp_level, "qf")
self.assertEqual(match.set_number, 2)
self.assertEqual(match.match_number, 3)
self.assertEqual(match.team_key_names, [u'frc716', u'frc3125', u'frc181', u'frc1699', u'frc1124', u'frc714'])
self.assertEqual(match.alliances_json, """{"blue": {"score": 74, "teams": ["frc1699", "frc1124", "frc714"]}, "red": {"score": 90, "teams": ["frc716", "frc3125", "frc181"]}}""")
self.assertEqual(match.time_string, "2:05 PM")
# Test 2011ct_f1m2
match = matches[-1]
self.assertEqual(match.comp_level, "f")
self.assertEqual(match.set_number, 1)
self.assertEqual(match.match_number, 2)
self.assertEqual(match.team_key_names, [u'frc195', u'frc1923', u'frc155', u'frc177', u'frc175', u'frc1073'])
self.assertEqual(match.alliances_json, """{"blue": {"score": 65, "teams": ["frc177", "frc175", "frc1073"]}, "red": {"score": 97, "teams": ["frc195", "frc1923", "frc155"]}}""")
self.assertEqual(match.time_string, "3:23 PM")
示例4: get
# 需要导入模块: from datafeeds.datafeed_usfirst import DatafeedUsfirst [as 别名]
# 或者: from datafeeds.datafeed_usfirst.DatafeedUsfirst import getMatches [as 别名]
def get(self, event_key):
df = DatafeedUsfirst()
event = Event.get_by_id(event_key)
new_matches = MatchManipulator.createOrUpdate(df.getMatches(event))
try:
last_matches = MatchHelper.recentMatches(new_matches, 1)
upcoming_matches = MatchHelper.upcomingMatches(new_matches, 8)
except:
logging.warning("Computing last/upcoming matches for Firebase failed!")
try:
FirebasePusher.updateEvent(event, last_matches, upcoming_matches)
except:
logging.warning("Enqueuing Firebase push failed!")
template_values = {
'matches': new_matches,
}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_matches_get.html')
self.response.out.write(template.render(path, template_values))