Creates IDs for both players/teams
323482
def _create_ids(self, home_teams, away_teams):
        
        categories = pd.Categorical(np.append(home_teams,away_teams))
        home_id, away_id = categories.codes[0:int(len(categories)/2)], categories.codes[int(len(categories)/2):len(categories)+1]
        return home_id, away_id
1241377
def is_in_team(self, team_id):
        """"""

        if self.is_super_admin():
            return True
        team_id = uuid.UUID(str(team_id))
        return team_id in self.teams or team_id in self.child_teams_ids
1083870
def load_from_id(gid)
      @gid = gid
      @rosters = []
      @umpires = {}
      @xml_data = GamedayFetcher.fetch_players(gid)
      @xml_doc = REXML::Document.new(@xml_data)
      if @xml_doc.root
        self.set_rosters
        self.set_umpires
      end
    end
126573
def load_from_id(gid, pid)
      @gid = gid
      @pid = pid
      # fetch players.xml file
      @xml_data = GamedayFetcher.fetch_players(gid)
      @xml_doc = REXML::Document.new(@xml_data)
      # find specific player in the file
      pelement = @xml_doc.root.elements["team/player[@id=#{pid}]"]
      init(pelement, gid)
    end
1027405
def players(game_id):
    """"""
    # get data
    data = mlbgame.data.get_players(game_id)
    # parse data
    parsed = etree.parse(data)
    root = parsed.getroot()

    output = {}
    output['game_id'] = game_id

    # get player/coach data
    for team in root.findall('team'):
        type = team.attrib['type'] + "_team"
        # the type is either home_team or away_team
        output[type] = {}
        output[type]['players'] = []
        output[type]['coaches'] = []

        for p in team.findall('player'):
            player = {}
            for key in p.keys():
                player[key] = p.get(key)
            output[type]['players'].append(player)

        for c in team.findall('coach'):
            coach = {}
            for key in c.keys():
                coach[key] = c.get(key)
            output[type]['coaches'].append(coach)

    # get umpire data
    output['umpires'] = []
    for u in root.find('umpires').findall('umpire'):
        umpire = {}
        for key in u.keys():
            umpire[key] = u.get(key)
        output['umpires'].append(umpire)

    return output
1135140
def attach_team(context, id, team_id):
    
    team_id = team_id or identity.my_team_id(context)
    result = topic.attach_team(context, id=id, team_id=team_id)
    utils.format_output(result, context.format)
1251152
def team_players(self, team):
        """"""
        keys = 'shirtNumber name position nationality dateOfBirth'.split()
        data = [{key: player[key] for key in keys} for player in team]
        self.generate_output({'players': data})
1180416
function computeGame(match, teamId, goalsMade, goalsTaken){
                // Skip empty id's
                if(!teamId)
                    return;

                // Generate default template if NOT in array yet
                if(!rawTable[teamId]){
                    var teamRow = _.clone(_default);
                    // Keeps team id under team
                    teamRow.teamId = teamId;
                    // Inserts team in rawTable
                    rawTable[teamId] = teamRow;
                }

                // Get teamRow (it is supposed to exist)
                var teamRow = rawTable[teamId];

                // Compute points ONLY if match is not 'scheduled'
                // logycaly, it's 'ended' or 'playing', so we compute it
                if(match.state == 'scheduled')
                    return;

                // Increment Plays
                teamRow.P++;

                // Compute goals made/taken
                teamRow.goalsMade += goalsMade*1;
                teamRow.goalsTaken += goalsTaken*1;

                // Win
                if(goalsMade > goalsTaken)
                    teamRow.W ++;
                // Loose
                else if(goalsMade < goalsTaken)
                    teamRow.L ++;
                // Drew
                else
                    teamRow.D ++;
            }
868497
def create(
            self, request, parent_lookup_seedteam=None,
            parent_lookup_seedteam__organization=None):
        ''''''
        team = self.check_team_permissions(
            request, parent_lookup_seedteam,
            parent_lookup_seedteam__organization)

        serializer = self.get_serializer(data=request.data)
        serializer.is_valid(raise_exception=True)
        permission = team.permissions.create(**serializer.validated_data)
        serializer = self.get_serializer(instance=permission)
        return Response(serializer.data, status=status.HTTP_201_CREATED)
283996
function createTeam (params, opts, cb) {
      if (!cb) {
        cb = opts
      }
      if (!opts || typeof opts === 'function') {
        opts = {}
      }

      let promise = null
      if (typeof cb !== 'function') [promise, cb] = asyncify()

      const { createOnly } = opts
      const tasks = [
        (job, next) => {
          const { id, name, description, metadata, parentId, organizationId, user } = params

          // We should not use boom but return specific errors that will be then handled out side the udaru.js module
          Joi.validate({ id, name, description, metadata, parentId, organizationId, user }, validationRules.createTeam, (err) => {
            if (err) return next(Boom.badRequest(err))
            next()
          })
        },
        (job, next) => {
          job.params = params
          next()
        },
        insertTeam
      ]
      if (!createOnly) {
        tasks.push(
          createDefaultPolicies,
          createDefaultUser,
          makeDefaultUserAdmin,
          assignDefaultUserToTeam
        )
      }

      db.withTransaction(tasks, (err, res) => {
        if (err) return cb(err)
        teamOps.readTeam({ id: res.team.id, organizationId: params.organizationId }, cb)
      })

      return promise
    }
1350265
def set_teams
    	@xml_doc.elements.each("game/team[@home_team='false']") do |element| 
    		@away_team = element.attributes["name"]
    	end
    	@xml_doc.elements.each("game/team[@home_team='true']") do |element| 
    		@home_team = element.attributes["name"]
    	end
    end
812706
function(id, gameGroup, options) {
  options = options || {};
  this.id = id;
  this.gameGroup = gameGroup;
  this.players = {};
  this.numPlayers = 0;
  this.sendQueue = [];
  this.options = options;
  this.setGameId();
  debug("create game " + this.gameId);
}
416149
def url(sport, league_id, team_id, start_date=None):
    
    url = '%s/%s/%s/' % (SPORT_URLS[sport], league_id, team_id)
    if start_date is not None:
        url += 'team?&date=%s' % start_date
    return url
472526
def init(element, gid)
      self.gid = gid
      self.team_name = element.attributes['name']
      self.id = element.attributes['id']
      self.type = element.attributes['type']
      self.players = []
      self.coaches = []
      self.set_players(element)
      self.set_coaches(element)
    end
999169
function createId(coll) {
  if (_.isEmpty(coll)) {
    return 1
  } else {
    var id = _.max(coll, function(doc) {
      return doc.id
    }).id

    if (_.isFinite(id)) {
      // Increment integer id
      return ++id
    } else {
      // Generate string id
      return uuid()
    }
  }
}
1009403
def create_team(self, name):
        ''' 

        '''
        request = self._get_request()
        return request.post(self.TEAM_CREATE_URL, {"name": name})
581189
def map_team_id(code):
    """"""
    for team in TEAM_DATA:
        if team["code"] == code:
            click.secho(team["name"], fg="green")
            break
    else:
        click.secho("No team found for this code", fg="red", bold=True)