本文整理汇总了Python中DataModel.mapAllValuesToShortenedString方法的典型用法代码示例。如果您正苦于以下问题:Python DataModel.mapAllValuesToShortenedString方法的具体用法?Python DataModel.mapAllValuesToShortenedString怎么用?Python DataModel.mapAllValuesToShortenedString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataModel
的用法示例。
在下文中一共展示了DataModel.mapAllValuesToShortenedString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_team_scouting_data_summary_json
# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import mapAllValuesToShortenedString [as 别名]
def get_team_scouting_data_summary_json(global_config, comp, name, attr_filter=[], filter_name=None, store_json_file=False):
global_config['logger'].debug( 'GET Team %s Scouting Data For Competition %s', name, comp )
season = WebCommonUtils.map_comp_to_season(comp)
session = DbSession.open_db_session(global_config['db_name'] + season)
if global_config['attr_definitions'] == None:
return None
attrdef_filename = WebCommonUtils.get_attrdef_filename(comp=comp)
attr_definitions = AttributeDefinitions.AttrDefinitions(global_config)
attr_definitions.parse(attrdef_filename)
result = []
result.append('{ "competition" : "%s", "team" : "%s",\n' % (comp,name))
result.append(' "scouting_data_summary" : [\n')
team_attributes = DataModel.getTeamAttributesInOrder(session, name, comp)
if len(team_attributes) > 0:
some_attr_added = False
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 an attribute filter has been provided, only include the attribute data if the
# attribute is in the filter
if len(attr_filter) > 0:
if attr_def['Name'] not in attr_filter:
include_attr = False
if include_attr == True:
some_attr_added = True
if attr_def.has_key('Display_Name'):
attr_name = attr_def['Display_Name']
else:
attr_name = attr_def['Name']
category = attr_def.get('Sub_Category', '')
result.append(' { "name": "%s", "matches": "%s", "cumulative_value": "%s", "average_value": "%s", "all_values": "%s", "category": "%s" }' % \
(attr_name,str(attribute.num_occurs),str(attribute.cumulative_value),str(round(attribute.avg_value,1)),\
DataModel.mapAllValuesToShortenedString(attr_def, attribute.all_values), category) )
result.append(',\n')
if some_attr_added:
result = result[:-1]
result.append(' ] }\n')
json_str = ''.join(result)
if store_json_file is True:
try:
FileSync.put( global_config, '%s/EventData/TeamData/team%s_scouting_data_summary.json' % (comp,name), 'text', json_str)
except:
raise
session.remove()
return json_str