当前位置: 首页>>代码示例>>Python>>正文


Python DataModel.mapAllValuesToShortenedString方法代码示例

本文整理汇总了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
开发者ID:FRCTeam1073-TheForceTeam,项目名称:ScoutingAppCentral,代码行数:70,代码来源:WebTeamData.py


注:本文中的DataModel.mapAllValuesToShortenedString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。