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


Python DataModel.mapValueToString方法代码示例

本文整理汇总了Python中DataModel.mapValueToString方法的典型用法代码示例。如果您正苦于以下问题:Python DataModel.mapValueToString方法的具体用法?Python DataModel.mapValueToString怎么用?Python DataModel.mapValueToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataModel的用法示例。


在下文中一共展示了DataModel.mapValueToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_team_attributes_page

# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import mapValueToString [as 别名]
def get_team_attributes_page(global_config):
        
    global_config['logger'].debug( 'GET Team Attributes' )
    
    session = DbSession.open_db_session(global_config['db_name'] + global_config['this_season'])
    comp = global_config['this_competition'] + global_config['this_season']

    attrdef_filename = WebCommonUtils.get_attrdef_filename(comp=comp)
    attr_definitions = AttributeDefinitions.AttrDefinitions(global_config)
    attr_definitions.parse(attrdef_filename)
    
    web.header('Content-Type', 'application/json')
    result = []
    result.append('{ "attributes": [\n')
    team_rankings = DataModel.getTeamsInRankOrder(session, comp)
    for team_entry in team_rankings:
        result.append("{ 'Team': " + str(team_entry.team))
        result.append(", 'Score': " + '%.2f' % team_entry.score )
        team_attributes = DataModel.getTeamAttributesInOrder(session, team_entry.team, comp)
        for attribute in team_attributes:
            attr_def = attr_definitions.get_definition( attribute.attr_name )
            if attr_def:
                weight = int(float(attr_def['Weight']))
                if weight != 0:
                    result.append( ", '" + attribute.attr_name + "': ")
                    if ( attr_def['Statistic_Type'] == 'Total'):
                        #result.append( str(attribute.cumulative_value) )
                        result.append( DataModel.mapValueToString(attribute.cumulative_value, attribute.all_values, attr_def, True) )
                    elif ( attr_def['Statistic_Type'] == 'Average'):
                        #result.append( str(attribute.avg_value) )
                        result.append( DataModel.mapValueToString(attribute.avg_value, attribute.all_values, attr_def, True) )
                    else:
                        #result.append( str(attribute.attr_value) )
                        result.append( DataModel.mapValueToString(attribute.attr_value, attribute.all_values, attr_def, True) )
                    
        result.append(' }')
        result.append(',\n')
    if len(team_rankings) > 0:
        result = result[:-1]
        result.append('\n')
    result.append(']}')
    session.remove()
    return ''.join(result)
开发者ID:FRCTeam1073-TheForceTeam,项目名称:ScoutingAppCentral,代码行数:45,代码来源:WebTeamData.py

示例2: str

# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import mapValueToString [as 别名]
    # Get the list of teams in rank order, then loop through teams and dump their stored
    # attribute values
    team_rankings = DataModel.getTeamsInRankOrder(session, competition)
    for team_entry in team_rankings:
        mystring = str(team_entry.team) + ',' + str(team_entry.score)
        # retrieve each attribute from the database in the proper order
        for attr_def in attr_order:
            if attr_def['Database_Store'] == 'Yes':
                attribute = DataModel.getTeamAttribute(session, team_entry.team, competition, attr_def['Name'])
                # if the attribute doesn't exist, just put in an empty field so that the columns
                # stay aligned
                if attribute == None:
                    mystring += ','
                elif ( attr_def['Statistic_Type'] == 'Total'):
                    #mystring += ',' + str(attribute.cumulative_value)
                    mystring += ',' + DataModel.mapValueToString(attribute.cumulative_value, attribute.all_values, attr_def)
                elif ( attr_def['Statistic_Type'] == 'Average'):
                    #mystring += ',' + str(attribute.avg_value)
                    mystring += ',' + DataModel.mapValueToString(attribute.avg_value, attribute.all_values, attr_def)
                else:
                    #mystring += ',' + str(attribute.attr_value)
                    mystring += ',' + DataModel.mapValueToString(attribute.attr_value, attribute.all_values, attr_def)

        mystring += '\n'
        fo.write( mystring )
    fo.close()

  
def process_files(session, db_name, attr_definitions, input_dir, recursive, test):
    # The following regular expression will select all files that conform to 
    # the file naming format Team*.txt. Build a list of all datafiles that match
开发者ID:mbhoude,项目名称:ScoutingAppCentral,代码行数:33,代码来源:ScoutingAppMain.py


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