本文整理汇总了Python中datafeeds.datafeed_usfirst.DatafeedUsfirst.getTeamDetails方法的典型用法代码示例。如果您正苦于以下问题:Python DatafeedUsfirst.getTeamDetails方法的具体用法?Python DatafeedUsfirst.getTeamDetails怎么用?Python DatafeedUsfirst.getTeamDetails使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datafeeds.datafeed_usfirst.DatafeedUsfirst
的用法示例。
在下文中一共展示了DatafeedUsfirst.getTeamDetails方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from datafeeds.datafeed_usfirst import DatafeedUsfirst [as 别名]
# 或者: from datafeeds.datafeed_usfirst.DatafeedUsfirst import getTeamDetails [as 别名]
def get(self, key_name):
df = DatafeedUsfirst()
legacy_df = DatafeedUsfirstLegacy()
team = df.getTeamDetails(Team.get_by_id(key_name))
if not team:
logging.warning("getTeamDetails with DatafeedUsfirst for event id {} failed. Retrying with DatafeedUsfirstLegacy.".format(key_name))
team = legacy_df.getTeamDetails(Team.get_by_id(key_name))
else:
legacy_team = legacy_df.getTeamDetails(Team.get_by_id(key_name))
if legacy_team is not None:
team.rookie_year = legacy_team.rookie_year # only available on legacy df
if team:
team = TeamManipulator.createOrUpdate(team)
success = True
else:
success = False
template_values = {
'key_name': key_name,
'team': team,
'success': success,
}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_team_details_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 getTeamDetails [as 别名]
def get(self, key_name):
# Combines data from three datafeeds with priorities:
# 1) DatafeedFMSAPI
# 2) DatafeedUsfirst (missing rookie year)
# 3) DatafeedUsfirstLegacy (has all info)
legacy_df = DatafeedUsfirstLegacy()
usfirst_df = DatafeedUsfirst()
fms_df = DatafeedFMSAPI('v2.0')
# Start with lowest priority
legacy_team = legacy_df.getTeamDetails(Team.get_by_id(key_name))
usfirst_team = usfirst_df.getTeamDetails(Team.get_by_id(key_name))
fms_details = fms_df.getTeamDetails(tba_config.MAX_YEAR, key_name)
# Separate out the multiple models returned from FMSAPI call
# Since we're only hitting one team at a time, the response won't
# ever be paginated so we can ignore the possibility
if fms_details and fms_details[0]:
models, more_pages = fms_details
fms_team, district_team, robot = models[0]
else:
fms_team = None
district_team = None
robot = None
team = None
if usfirst_team:
team = TeamManipulator.updateMergeBase(usfirst_team, legacy_team)
if fms_team:
team = TeamManipulator.updateMergeBase(fms_team, team)
if district_team:
district_team = DistrictTeamManipulator.createOrUpdate(district_team)
if robot:
robot = RobotManipulator.createOrUpdate(robot)
if team:
team = TeamManipulator.createOrUpdate(team)
success = True
else:
success = False
logging.warning("getTeamDetails failed for team: {}".format(key_name))
template_values = {
'key_name': key_name,
'team': team,
'success': success,
'district': district_team,
'robot': robot,
}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_team_details_get.html')
self.response.out.write(template.render(path, template_values))
示例3: TestDatafeedUsfirstTeams
# 需要导入模块: from datafeeds.datafeed_usfirst import DatafeedUsfirst [as 别名]
# 或者: from datafeeds.datafeed_usfirst.DatafeedUsfirst import getTeamDetails [as 别名]
class TestDatafeedUsfirstTeams(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()
self.team177 = Team(
id="frc177",
team_number=177,
first_tpid=61771,
first_tpid_year=2012
)
self.team177.put()
def tearDown(self):
self.testbed.deactivate()
def test_getTeamDetails(self):
team = self.datafeed.getTeamDetails(self.team177)
## Broken as result of FIRST website redesign -gregmarra 20151122
# self.assertEqual(team.name, "UTC Power/Ensign Bickford Aerospace & Defense & South Windsor High School")
# self.assertEqual(team.address, u"South Windsor, CT, USA")
# self.assertEqual(team.nickname, "Bobcat Robotics")
# self.assertEqual(team.website, "http://www.bobcatrobotics.org")
def test_getTeamsTpids(self):
Team(
id="frc4409",
team_number=4409,
first_tpid=0, # should be 74735
first_tpid_year=2011
).put()
# We can skip 2000 records, paginate, and still get frc4409 and frc4410 in 2012
self.datafeed.getTeamsTpids(2012, skip=2000)
# Check new team insertion
frc4410 = Team.get_by_id("frc4410")
self.assertEqual(frc4410.team_number, 4410)
self.assertEqual(frc4410.first_tpid, 74193)
self.assertEqual(frc4410.first_tpid_year, 2012)
# Check old team updating
frc4409 = Team.get_by_id("frc4409")
self.assertEqual(frc4409.team_number, 4409)
self.assertEqual(frc4409.first_tpid, 74735)
self.assertEqual(frc4409.first_tpid_year, 2012)
示例4: get
# 需要导入模块: from datafeeds.datafeed_usfirst import DatafeedUsfirst [as 别名]
# 或者: from datafeeds.datafeed_usfirst.DatafeedUsfirst import getTeamDetails [as 别名]
def get(self, key_name):
# Combines data from three datafeeds with priorities:
# 1) DatafeedFMSAPI (missing website)
# 2) DatafeedUsfirst (missing rookie year)
# 3) DatafeedUsfirstLegacy (has all info)
legacy_df = DatafeedUsfirstLegacy()
usfirst_df = DatafeedUsfirst()
fms_df = DatafeedFMSAPI('v2.0')
# Start with lowest priority
legacy_team = legacy_df.getTeamDetails(Team.get_by_id(key_name))
usfirst_team = usfirst_df.getTeamDetails(Team.get_by_id(key_name))
fms_details = fms_df.getTeamDetails(date.today().year, key_name)
if fms_details:
fms_team, district_team, robot = fms_details
else:
fms_team = None
district_team = None
robot = None
team = None
if usfirst_team:
team = TeamManipulator.updateMergeBase(usfirst_team, legacy_team)
if fms_team:
team = TeamManipulator.updateMergeBase(fms_team, team)
if district_team:
district_team = DistrictTeamManipulator.createOrUpdate(district_team)
if robot:
robot = RobotManipulator.createOrUpdate(robot)
if team:
team = TeamManipulator.createOrUpdate(team)
success = True
else:
success = False
logging.warning("getTeamDetails failed for team: {}".format(key_name))
template_values = {
'key_name': key_name,
'team': team,
'success': success,
'district': district_team,
'robot': robot,
}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_team_details_get.html')
self.response.out.write(template.render(path, template_values))
示例5: get
# 需要导入模块: from datafeeds.datafeed_usfirst import DatafeedUsfirst [as 别名]
# 或者: from datafeeds.datafeed_usfirst.DatafeedUsfirst import getTeamDetails [as 别名]
def get(self, key_name):
df = DatafeedUsfirst()
team = df.getTeamDetails(Team.get_by_id(key_name))
if team:
team = TeamManipulator.createOrUpdate(team)
success = True
else:
success = False
template_values = {
'team': team,
'success': success,
}
path = os.path.join(os.path.dirname(__file__), '../templates/datafeeds/usfirst_team_details_get.html')
self.response.out.write(template.render(path, template_values))