Gets the live scores
339137
def get_live_scores(self, use_12_hour_format):
        """"""
        req = requests.get(RequestHandler.LIVE_URL)
        if req.status_code == requests.codes.ok:
            scores_data = []
            scores = req.json()
            if len(scores["games"]) == 0:
                click.secho("No live action currently", fg="red", bold=True)
                return

            for score in scores['games']:
                # match football-data api structure
                d = {}
                d['homeTeam'] = {'name': score['homeTeamName']}
                d['awayTeam'] = {'name': score['awayTeamName']}
                d['score'] = {'fullTime': {'homeTeam': score['goalsHomeTeam'],
                                           'awayTeam': score['goalsAwayTeam']}}
                d['league'] = score['league']
                d['time'] = score['time']
                scores_data.append(d)
            self.writer.live_scores(scores_data)
        else:
            click.secho("There was problem getting live scores", fg="red", bold=True)
97511
def winning_abbr(self):
        
        if self.winner == HOME:
            if 'cfb/schools' not in str(self._home_name):
                return self._home_name.text()
            return utils._parse_abbreviation(self._home_name)
        if 'cfb/schools' not in str(self._away_name):
            return self._away_name.text()
        return utils._parse_abbreviation(self._away_name)
692720
def current(self):
        
        rankings_dict = {}

        for team in self.current_extended:
            rankings_dict[team['abbreviation']] = team['rank']
        return rankings_dict
664945
def total_scores_in(self, leaderboard_name):
        '''
        
        '''
        return sum([leader[self.SCORE_KEY] for leader in self.all_leaders_from(self.leaderboard_name)])
515436
def scores(self, result, add_new_line=True):
        """"""
        if result.goalsHomeTeam > result.goalsAwayTeam:
            homeColor, awayColor = (self.colors.WIN, self.colors.LOSE)
        elif result.goalsHomeTeam < result.goalsAwayTeam:
            homeColor, awayColor = (self.colors.LOSE, self.colors.WIN)
        else:
            homeColor = awayColor = self.colors.TIE

        click.secho('%-25s %2s' % (result.homeTeam, result.goalsHomeTeam),
                    fg=homeColor, nl=False)
        click.secho("  vs ", nl=False)
        click.secho('%2s %s' % (result.goalsAwayTeam,
                                result.awayTeam.rjust(25)), fg=awayColor,
                    nl=add_new_line)
212788
function(key, data, callback) {
	'use strict';

	/**
	 * Read scores by values.
	 *
	 * @param {Array} values
	 * @param {Function} callback
	 */
	var ReadScores = function(values, callback) {
		var result = [];

		/**
		 * Get scores recursive.
		 */
		var GetRecursive = function() {
			if (!values.length) {
				callback(null, result);
				return;
			}

			var value = values.pop();

			this.getClient().zscore(key, value, function(err, score) {
				if (err) {
					callback(err);
					return;
				}

				result.push(score);
				GetRecursive();
			});
		}.bind(this);

		GetRecursive();
	}.bind(this);

	/**
	 * Read key.
	 *
	 * @param {String} key
	 * @param {String} type
	 * @param {Function} rkCallback
	 */
	var ReadKey = function(key, type, rkCallback) {
		var params = [ key ],
			command = {
				set: 'smembers',
				zset: 'zrange',
				list: 'lrange',
				hash: 'hgetall'
			}[ type ] || 'get';

		if (command.indexOf('range') !== -1) {
			params.push(0);
			params.push(-1);
		}

		params.push(function(err, values) {
			if (err) {
				rkCallback(err);
				return;
			}

			switch (type) {
				case 'zset':
					ReadScores(_.clone(values).reverse(), function(err, scores) {
						rkCallback(null, _.zip(scores, values));
					});
					break;

				default:
					rkCallback(null, values);
					break;
			}
		});

		this.getClient()[ command ].apply(this.getClient(), params);
	}.bind(this);


	switch (this.getExportParams().type) {
		//	Export as redis type.
		case 'redis':
			return function(err, type) {
				var type2PrintSetCommand = {
					string: 'SET',
					set: 'SADD',
					zset: 'ZADD',
					list: 'RPUSH',
					hash: 'HSET'
				};

				if (!data) {
					data = '';
				}

				ReadKey(key, type, function(err, value) {
					if (err) {
						callback(err);
						return;
					}

					var command = type2PrintSetCommand[ type ];

					key = key.trim();

					switch (type) {
						case 'set':
							_.each(value, function(item) {
								data += command + ' "' + key + '" "' + item + "\"\n";
							});
							break;

						case 'zset':
							_.each(value, function(item) {
								data += command + ' "' + key + '" ' + item[0] + ' "' + item[1] + "\"\n";
							});
							break;

						case 'hash':
							_.each(_.pairs(value), function(item) {
								data += command + ' "' + key + '" "' + item[0] + '" "' + item[1] + "\"\n";
							});
							break;

						default:
							data += command + ' "' + key + '" "' + value + "\"\n";
							break;
					}

					callback(null, data);
				});
			};

		//	Export as json type.
		case 'json':
			return function(err, type) {
				if (!data) {
					data = {};
				}

				ReadKey(key, type, function(err, value) {
					if (err) {
						callback(err);
						return;
					}

					switch (type) {
						case 'zset':
							var withoutScores = [];
							_.each(value, function(item) {
								withoutScores.push(item[1]);
							});
							value = withoutScores;
							break;
					}

					data[ key.trim() ] = value;

					callback(null, data);
				});
			};
	}
}
928304
def get_score_metadata(self):
        
        # Implemented from template for osid.resource.ResourceForm.get_group_metadata_template
        metadata = dict(self._mdata['score'])
        metadata.update({'existing_decimal_values': self._my_map['score']})
        return Metadata(**metadata)
609446
function under_score()
    {
        $key = (string) $this;

        $output = strtolower(preg_replace(array('/([a-z\d])([A-Z])/', '/([^_])([A-Z][a-z])/'), '$1_$2', $key));

        return new self($output);
    }
1079799
public function result()
    {

        // Don't bother if it didn't go well
        if ($this->_res == false) {
            return false;
        }

        // Store rows here
        $rows = [];

        // Table header
        $rows[] = array(
            'type' => 'header',
            'columns' => array(
                'Name',
                'Map',
                'Time Left',
                'Gametype',
                'Players',
            ),
        );

        // Have we?
        if (count($this->_res) == 0) {
            $rows[] = array('type' => 'none', 'columns' => array(array(5, 'None found')));
        }

        // We do
        else {

            // Go through each server
            foreach ($this->_res as $server) {

                // No players? Set player column to 'none'
                if ($server['info']['num_players'] == 0) {
                    $players = 'None';
                }

                // We do; populate a mini players table
                else {

                    // Show team column?
                    $show_team = in_array($server['info']['mode'], array(
                                'Infiltration',
                                'Capture the Flag',
                                'Teammatch',
                    ));

                    // Start table
                    $players = '
					<table class="mini" style="text-align: center;">
						<tr>
							<th>Name</th>'.(
                            $show_team ? '
							<th>Team</th>' : '').'
							<th>Score</th>
							<th>Deaths</th>
							<th>Ping</th>
						</tr>';

                    // Add each player to it
                    foreach ($server['info']['players'] as $player) {
                        $players .= '
						<tr'.($show_team ?  (' style="color: '.(
                        array_key_exists($player['team'], self::$team2color) ?
                            self::$team2color[$player['team']] : 'purple'
                        ).';"') : '').'>
							<td>'.htmlspecialchars($player['name']).'</td>'.(
                            $show_team ? '
							<td>'.(array_key_exists($player['team'], self::$team2name) ?
                                self::$team2name[$player['team']] : 'None').'</td>' : '').'
							<td>'.$player['kills'].'</td>
							<td>'.$player['deaths'].'</td>
							<td>'.$player['ping'].'</td>
						</tr>';
                    }

                    // End table
                    $players .= '
					</table>
					';
                }

                // Save result in master table
                $rows[] = array(
                    'type' => 'values',
                    'columns' => array(
                        $server['name'],
                        $server['info']['map'],
                        $server['info']['timeleft'],
                        $server['info']['mode'],
                        $players,
                    ),
                );
            }
        }

        // Give info
        return array(
            'root_title' => 'Soldat Servers',
            'rows' => $rows,
        );
    }
264483
def output(self):
        ""
        FScore.output_header()
        nts = list(self.nt_score.keys())
        nts.sort()
        for nt in nts:
            self.nt_score[nt].output_row(nt)
        print()
        self.total_score.output_row("total")
367500
def get_live_league_games(self):
        
        url = self.__build_url(urls.GET_LIVE_LEAGUE_GAMES)
        req = self.executor(url)
        if self.logger:
            self.logger.info('URL: {0}'.format(url))
        if not self.__check_http_err(req.status_code):
            return response.build(req, url, self.raw_mode)
222373
def box_score(game_id):
    """"""
    # get box score data
    data = mlbgame.game.box_score(game_id)
    # create object with data
    obj = mlbgame.game.GameBoxScore(data)
    return obj
1300035
def standings(date=datetime.now()):
    
    data = mlbgame.info.standings(date)
    return mlbgame.info.Standings(data)
1215797
function getAge (keyword, apps) {
    // FIXME this is a number in google play now
    const updated = R.pluck('updated', apps).map(getDaysSince);
    const avg = R.sum(updated) / apps.length;
    const max = 500;
    const score = calc.izScore(max, avg);

    return {
      avgDaysSinceUpdated: avg,
      score
    };
  }
740217
function generateTableDataInsideScores(table){
	// Save to allow in function referencte
	table = table || this;
	var columns = table.columns*1;

	/*
		Create data table
	*/
	var scores = table.scores;

	// Just warn (DEBUG mode...)
	if(!scores)
		console.log('Table is empty!');

	// Get evaluation method ('min', 'max', custom...)
	var evalMethod = getMethodFor(table.evaluateMethod);

	// List of all the keys to sort
	var keysToSort = ['final'];

	// Go through all scores, creating a unique row
	_(scores).forEach(function(score){
		/*
			Notice score structure:

			{
				tableId: [this table id]
				teamId: xxx,
				scores: {
					  0: {value: xxx, data: {}},
					'1': {value: xxx, data: {}},
					  2: {value: xxx, data: {}}
					  [...],
				}
			}
		*/

		// This will be the object inserted in the table's data array
		// var scoreData = {};

		// Add simple attributes
		// scoreData['id'] = score.id || null;
		// scoreData['teamId'] = score.teamId || null;
		// scoreData['tableId'] = score.tableId || null;
		// scoreData['team'] = score.teamId || null;
		// scoreData.team: score.team.name
		// scoreData.country: score.team.country

		// Add scores data
		var scoreValues = [];
		for(var i = 0; i < columns; i++){

			// Get value and add to scoreValues
			var value = null;
			if(score.scores[i])
				value = score.scores[i].value;

			scoreValues.push(value);

			// Generate field key and saves
			// var field = 'score.'+(i+1);
			// score[field] = score.scores.value || null;
		}

		// Compute final score and adds to scoreData
		var finalScores = '?';

		// If evalMethod is set, let's compute the score. 
		if(evalMethod) {
			finalScores = evalMethod(scoreValues) || 0;
		}

		var showScore = finalScores;

		if(_.isArray(finalScores)){
			showScore = finalScores[0];

			for(var i = 1; i < finalScores.length; i++){
				var fieldKey = 'final'+(i+1); // Like: final2, final3, ...
				score[fieldKey] = finalScores[i];

				if(keysToSort.length <= i)
					keysToSort.push(fieldKey);
			}
		}

		score['final'] = showScore;

		// Add to table data
		// tableRows.push(score)
	});

	// Sort by 'final' field and reverse if needed
	var finalData = _.sortBy(scores, keysToSort);

	if(table.sort == 'desc')
		finalData = finalData.reverse();

	// Rank Table
	var pos = 0;
	var lastRow = null;

	_.forEach(finalData, function(row){
		pos++;

		var sameRanking = (lastRow ? true : false);
		for(var k in keysToSort){
			var key = keysToSort[k];
			if(lastRow && lastRow[key] != row[key]){
				sameRanking = false;
				break;
			}
		}

		if(sameRanking){
			// Keeps the same ranking if scores are the same
			return row.rank = lastRow.rank;
		}else{
			// Set rank as current position
			row.rank = pos;

		}
		// Save current row as last one
		lastRow = row;
	});

	// Self assign the table
	this.scores = finalData;

	// Return the table
	return this.scores;
}
610120
def live_weather(self, live_weather):
        """"""
        summary = live_weather['currently']['summary']
        self.summary(summary)
        click.echo()
969494
def box_score(game_id):
    """"""
    # get data
    data = mlbgame.data.get_box_score(game_id)
    # parse data
    parsed = etree.parse(data)
    root = parsed.getroot()
    linescore = root.find('linescore')
    result = dict()
    result['game_id'] = game_id
    # loop through innings and add them to output
    for x in linescore:
        inning = x.attrib['inning']
        home = value_to_int(x.attrib, 'home')
        away = value_to_int(x.attrib, 'away')
        result[int(inning)] = {'home': home, 'away': away}
    return result