本文整理汇总了Python中DataModel.getTeamInfo方法的典型用法代码示例。如果您正苦于以下问题:Python DataModel.getTeamInfo方法的具体用法?Python DataModel.getTeamInfo怎么用?Python DataModel.getTeamInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataModel
的用法示例。
在下文中一共展示了DataModel.getTeamInfo方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_team_info_json
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import getTeamInfo [as 别名]
def get_team_info_json(global_config, comp, name, store_json_file=False):
global_config['logger'].debug( 'GET Team %s Info', name )
season = WebCommonUtils.map_comp_to_season(comp)
session = DbSession.open_db_session(global_config['db_name'] + season)
team_info = DataModel.getTeamInfo(session, int(name))
if team_info is None:
json_str = ''
else:
result = []
result.append('{ "team": "%s", "team_data" : [\n' % name)
result.append(' { "name": "%s", "value": "%s" }' % ('nickname', team_info.nickname))
result.append(',\n')
result.append(' { "name": "%s", "value": "%s" }' % ('affiliation', team_info.fullname))
result.append(',\n')
result.append(' { "name": "%s", "value": "%s" }' % ('location', team_info.location))
result.append(',\n')
result.append(' { "name": "%s", "value": "%s" }' % ('rookie_season', team_info.rookie_season))
result.append(',\n')
result.append(' { "name": "%s", "value": "%s" }' % ('website', team_info.website))
result.append('\n')
result.append(' ] }\n')
json_str = ''.join(result)
if store_json_file is True:
try:
FileSync.put( global_config, '%s/EventData/TeamData/team%s_teaminfo.json' % (comp,name), 'text', json_str)
except:
raise
return json_str
示例2: get_team_list_json
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import getTeamInfo [as 别名]
def get_team_list_json(global_config, comp):
global team_info_dict
global_config['logger'].debug( 'GET Team List For Competition %s', comp )
session = DbSession.open_db_session(global_config['db_name'])
web.header('Content-Type', 'application/json')
result = []
result.append('{ "teams" : [\n')
team_list = DataModel.getTeamsInNumericOrder(session, comp)
for team in team_list:
team_info = None
# TODO - Remove this hardcoded number for the valid team number. This check prevents
# requesting information for invalid team numbers, which has been known to happen when
# tablet operators enter bogus team numbers by mistake
if team.team < 10000:
team_info = DataModel.getTeamInfo(session, int(team.team))
if team_info:
result.append(' { "team_number": "%s", "nickname": "%s" }' % (team.team,team_info.nickname))
result.append(',\n')
if len(team_list) > 0:
result = result[:-1]
result.append(' ] }\n')
return ''.join(result)
else:
return get_team_list_json_from_tba(global_config, comp)
示例3: get_team_info_str
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import getTeamInfo [as 别名]
def get_team_info_str(team):
my_config = ScoutingAppMainWebServer.global_config
session = DbSession.open_db_session(my_config["db_name"] + my_config["this_season"])
team_info_str = list()
team_info = DataModel.getTeamInfo(session, int(team))
if team_info:
team_info_str.append(("Team Nickname", team_info.nickname, "string"))
team_info_str.append(("Affiliation", team_info.fullname, "string"))
team_info_str.append(("Location", team_info.location, "string"))
team_info_str.append(("Rookie Season", team_info.rookie_season, "string"))
team_info_str.append(("Website", team_info.website, "link"))
return team_info_str
示例4: get_team_info_str
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import getTeamInfo [as 别名]
def get_team_info_str(team):
my_config = ScoutingAppMainWebServer.global_config
session = DbSession.open_db_session(my_config['db_name'])
team_info_str=list()
team_info = DataModel.getTeamInfo(session, int(team))
if team_info:
team_info_str.append(('Team Nickname',team_info.nickname,'string'))
team_info_str.append(('Affiliation',team_info.fullname,'string'))
team_info_str.append(('Location',team_info.location,'string'))
team_info_str.append(('Rookie Season',team_info.rookie_season,'string'))
team_info_str.append(('Website',team_info.website,'link'))
return team_info_str
示例5: get_team_list_json
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import getTeamInfo [as 别名]
def get_team_list_json(global_config, comp, store_json_file=False):
global team_info_dict
global_config['logger'].debug( 'GET Team List For Competition %s', comp )
season = WebCommonUtils.map_comp_to_season(comp)
session = DbSession.open_db_session(global_config['db_name'] + season)
result = []
result.append('{ "teams" : [\n')
team_list = DataModel.getTeamsInNumericOrder(session, comp)
for team in team_list:
team_info = None
# TODO - Remove this hardcoded number for the valid team number. This check prevents
# requesting information for invalid team numbers, which has been known to happen when
# tablet operators enter bogus team numbers by mistake
if team.team < 10000:
team_info = DataModel.getTeamInfo(session, int(team.team))
if team_info:
result.append(' { "team_number": "%s", "nickname": "%s" }' % (team.team,team_info.nickname))
result.append(',\n')
else:
result.append(' { "team_number": "%s", "nickname": "%s" }' % (team.team,'Unknown'))
result.append(',\n')
if len(team_list) > 0:
result = result[:-1]
result.append(' ] }\n')
json_str = ''.join(result)
else:
json_str = get_team_list_json_from_tba(global_config, comp)
if store_json_file is True:
try:
FileSync.put( global_config, '%s/EventData/%s.json' % (comp,'teams'), 'text', json_str)
except:
raise
return json_str
示例6: get_team_info_json
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import getTeamInfo [as 别名]
def get_team_info_json(global_config, name):
global_config['logger'].debug( 'GET Team %s Info', name )
session = DbSession.open_db_session(global_config['db_name'])
team_info = DataModel.getTeamInfo(session, int(name))
web.header('Content-Type', 'application/json')
result = []
result.append('{ "team": "%s", "team_data" : [\n' % name)
result.append(' { "name": "%s", "value": "%s" }' % ('nickname', team_info.nickname))
result.append(',\n')
result.append(' { "name": "%s", "value": "%s" }' % ('affiliation', team_info.fullname))
result.append(',\n')
result.append(' { "name": "%s", "value": "%s" }' % ('location', team_info.location))
result.append(',\n')
result.append(' { "name": "%s", "value": "%s" }' % ('rookie_season', team_info.rookie_season))
result.append(',\n')
result.append(' { "name": "%s", "value": "%s" }' % ('website', team_info.website))
result.append('\n')
result.append(' ] }\n')
return ''.join(result)
示例7: get_team_datafiles_page
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import getTeamInfo [as 别名]
def get_team_datafiles_page(global_config, name, display_notes=True):
global_config['logger'].debug( 'GET Team Data Files: %s', name )
if global_config['attr_definitions'] == None:
return None
session = DbSession.open_db_session(global_config['db_name'] + global_config['this_season'])
page=''
team_info = DataModel.getTeamInfo(session, int(name))
if team_info:
page += '<h3>Team Info</h3>'
page += '<li>Team Nickname: ' + team_info.nickname + '</li>'
page += '<li>Affiliation: ' + team_info.fullname + '</li>'
page += '<li>Location: ' + team_info.location + '</li>'
page += '<li>Rookie Season: ' + str(team_info.rookie_season) + '</li>'
page += '<li>Website: <a href="' + team_info.website + '">' + team_info.website + '</a></li>'
page += '<br>'
competitions = []
this_comp = global_config['this_competition']
season = global_config['this_season']
competitions.append(this_comp+season)
competitions_str = global_config['other_competitions']
competitions_str = competitions_str.replace(this_comp,'')
if competitions_str.count(',') > 0:
other_comps = competitions_str.split(',')
for other_comp in other_comps:
if other_comp != '':
competitions.append(other_comp+season)
elif competitions_str != '':
competitions.append(competitions_str+season)
for comp in competitions:
if comp != '':
attrdef_filename = WebCommonUtils.get_attrdef_filename(comp=comp)
attr_definitions = AttributeDefinitions.AttrDefinitions(global_config)
attr_definitions.parse(attrdef_filename)
input_dir = './static/data/' + comp + '/ScoutingData/'
pattern = 'Team' + name + '_' + '[a-zA-Z0-9_]*.txt'
datafiles = get_datafiles(input_dir, re.compile(pattern), False, global_config['logger'])
input_dir = './static/data/' + comp + '/ScoutingPictures/'
pattern = 'Team' + name + '_' + '[a-zA-Z0-9_]*.jpg|mp4'
mediafiles = get_datafiles(input_dir, re.compile(pattern), False, global_config['logger'])
if len(datafiles) == 0 and len(mediafiles) == 0:
continue
page += '<hr>'
page += '<h3> ' + comp + '</h3>'
team_attributes = DataModel.getTeamAttributesInOrder(session, name, comp)
if len(team_attributes) > 0:
page += '<ul>'
page += '<h3>Scouting Data Summary:</h3>'
page += '<ul>'
page += '<table border="1" cellspacing="5">'
page += '<tr>'
page += '<th>Attribute Name</th>'
page += '<th>Matches</th>'
page += '<th>Cumulative Value</th>'
page += '<th>Average Value</th>'
#page += '<th>Last Value</th>'
page += '<th>All Values</th>'
page += '</tr>'
for attribute in team_attributes:
attr_def = attr_definitions.get_definition( attribute.attr_name )
include_attr = False
if attr_def:
if attr_def.has_key('Include_In_Team_Display') \
and attr_def['Include_In_Team_Display'] == 'Yes':
include_attr = True
elif attr_def.has_key('Include_In_Report') \
and attr_def['Include_In_Report'] == 'Yes':
include_attr = True
elif attr_def.has_key('Weight') \
and attr_def['Weight'] != '0':
include_attr = True
if include_attr == True:
page += '<tr>'
if attr_def.has_key('Display_Name'):
page += '<td>%s</td>' % attr_def['Display_Name']
else:
page += '<td>%s</td>' % attr_def['Name']
page += '<td>%s</td>' % str(attribute.num_occurs)
page += '<td>%s</td>' % str(attribute.cumulative_value)
page += '<td>%0.2f</td>' % (attribute.avg_value)
#page += '<td>%s</td>' % str(attribute.attr_value)
page += '<td>%s</td>' % attribute.all_values
page += '</tr>'
#.........这里部分代码省略.........