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


Python DataModel.getTeamAttributesInOrder方法代码示例

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


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

示例1: get_team_score_breakdown_json

# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import getTeamAttributesInOrder [as 别名]
def get_team_score_breakdown_json(global_config, name, comp=None, store_json_file=False):
        
    global_config['logger'].debug( 'GET Team Score Breakdown: %s', name )
    
    if comp == None:
        comp = global_config['this_competition'] + global_config['this_season']
        season = global_config['this_season']
    else:
        season = WebCommonUtils.map_comp_to_season(comp)
    session = DbSession.open_db_session(global_config['db_name'] + season)
    
    attrdef_filename = WebCommonUtils.get_attrdef_filename(comp=comp)
    attr_definitions = AttributeDefinitions.AttrDefinitions(global_config)
    attr_definitions.parse(attrdef_filename)
    
    result = []

    result.append('{ "score_breakdown": [\n')

    team_attributes = DataModel.getTeamAttributesInOrder(session, name, comp)
    for attribute in team_attributes:
        attr_def = attr_definitions.get_definition( attribute.attr_name )
        if attr_def:
            try:
                stat_type = attr_def['Statistic_Type']
            except:
                stat_type = 'Total'

            weight = int(float(attr_def['Weight']))
            if weight != 0:
                if stat_type == 'Average':
                    value = int(attribute.cumulative_value/attribute.num_occurs)
                else:
                    value = int(attribute.cumulative_value)
                data_str = '{"attr_name": "%s", "raw_score": %d, "weighted_score": %d}' % (attribute.attr_name,int(value),int(weight*value)) 
                result.append(data_str)
                result.append(',\n')
    if len(team_attributes) > 0:
        result = result[:-1]
        result.append('\n')
    result.append(']}')
    
    json_str = ''.join(result)
    
    if store_json_file is True:
        try:
            FileSync.put( global_config, '%s/EventData/TeamData/team%s_scouting_scorebreakdown.json' % (comp,name), 'text', json_str)
        except:
            raise
        
    session.remove()
    return json_str
开发者ID:FRCTeam1073-TheForceTeam,项目名称:ScoutingAppCentral,代码行数:54,代码来源:WebTeamData.py

示例2: get_team_scouting_data_summary_json

# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import getTeamAttributesInOrder [as 别名]
def get_team_scouting_data_summary_json(global_config, comp, name):
    
    global_config['logger'].debug( 'GET Team %s Scouting Data For Competition %s', name, comp )
    session = DbSession.open_db_session(global_config['db_name'])

    if global_config['attr_definitions'] == None:
        return None
    
    attrdef_filename = './config/' + global_config['attr_definitions']
    attr_definitions = AttributeDefinitions.AttrDefinitions()
    attr_definitions.parse(attrdef_filename)

    web.header('Content-Type', 'application/json')
    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.has_key('Weight') != '0':
                    include_attr = True

            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']
                result.append('   { "name": "%s", "matches": "%s", "cumulative_value": "%s", "average_value": "%s", "all_values": "%s" }' % \
                              (attr_name,str(attribute.num_occurs),str(attribute.cumulative_value),str(attribute.avg_value),attribute.all_values ))
                result.append(',\n')
        if some_attr_added:
            result = result[:-1]
        
    result.append(' ] }\n')
    return ''.join(result)
开发者ID:mbhoude,项目名称:ScoutingAppCentral,代码行数:51,代码来源:WebTeamData.py

示例3: get_team_attributes_page

# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import getTeamAttributesInOrder [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

示例4: get_team_score_breakdown_page

# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import getTeamAttributesInOrder [as 别名]
def get_team_score_breakdown_page(global_config, name, comp=None):
        
    global_config['logger'].debug( 'GET Team Score Breakdown: %s', name )
    
    session = DbSession.open_db_session(global_config['db_name'])
    
    attrdef_filename = './config/' + global_config['attr_definitions']
    attr_definitions = AttributeDefinitions.AttrDefinitions()
    attr_definitions.parse(attrdef_filename)
    
    web.header('Content-Type', 'application/json')
    result = []

    result.append('{ "score_breakdown": [\n')
    if comp == None:
        comp = global_config['this_competition'] + global_config['this_season']
    team_attributes = DataModel.getTeamAttributesInOrder(session, name, comp)
    for attribute in team_attributes:
        attr_def = attr_definitions.get_definition( attribute.attr_name )
        if attr_def:
            try:
                stat_type = attr_def['Statistic_Type']
            except:
                stat_type = 'Total'

            weight = int(float(attr_def['Weight']))
            if weight != 0:
                if stat_type == 'Average':
                    value = int(attribute.cumulative_value/attribute.num_occurs)
                else:
                    value = int(attribute.cumulative_value)
                data_str = '{"attr_name": "%s", "raw_score": %d, "weighted_score": %d}' % (attribute.attr_name,int(value),int(weight*value)) 
                result.append(data_str)
                result.append(',\n')
    if len(team_attributes) > 0:
        result = result[:-1]
        result.append('\n')
    result.append(']}')
    
    return ''.join(result)
开发者ID:mbhoude,项目名称:ScoutingAppCentral,代码行数:42,代码来源:WebTeamData.py

示例5: get_team_datafiles_page

# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import getTeamAttributesInOrder [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>'
                        
#.........这里部分代码省略.........
开发者ID:FRCTeam1073-TheForceTeam,项目名称:ScoutingAppCentral,代码行数:103,代码来源:WebTeamData.py

示例6: get_team_scouting_data_summary_json

# 需要导入模块: import DataModel [as 别名]
# 或者: from DataModel import getTeamAttributesInOrder [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.getTeamAttributesInOrder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。