

def __init__(self, game, key, meta_data, index):
    self.user_scores = {
        
    }
    self.scores = []
    self.aggregate = False
    self.aggregate_score = 0
    self.lock = Lock()
    self.errors = []
    self.warnings = []
    self.path = None

    def error(msg):
        self.errors.append(msg)

    def warning(msg):
        self.warnings.append(msg)
    if (not self.validate_key.match(key)):
        error(('invalid key format "%s"' % key))
    self.key = key
    self.index = index
    if (('title' not in meta_data) or (meta_data['title'] is None)):
        error(('title property missing for key "%s"' % key))
        self.title = ''
    else:
        self.title = meta_data['title']
    if ('aggregate' in meta_data):
        if isinstance(meta_data['aggregate'], bool):
            self.aggregate = meta_data['aggregate']
        else:
            warning(('aggregate property must be a boolean for key "%s"' % key))
            self.aggregate = False
    else:
        self.aggregate = False
    try:
        sort_by = int(meta_data['sortBy'])
        if ((sort_by != (- 1)) and (sort_by != 1)):
            error(('sortBy must either -1 or 1 for key "%s"' % key))
    except KeyError:
        warning(('sortBy property missing for key "%s"' % key))
        sort_by = 1
    except ValueError:
        error(('sortBy must either -1 or 1 for key "%s"' % key))
        sort_by = 1
    self.sort_by = sort_by
    if ('icon' in meta_data):
        warning(('"icon" yaml property has been deprecated please use "icon256", "icon48" or "icon32" for leaderboard key "%s"' % key))
    try:
        icon_path = meta_data['icon256']
        if path_exists(get_absolute_path(join_path(game.path, icon_path))):
            if (splitext(icon_path)[1] != '.png'):
                warning(('icon256 must be in PNG format for key "%s"' % key))
        else:
            error(('icon256 file does not exist for key "%s"' % key))
    except KeyError:
        warning(('no icon256 (using default) for key "%s"' % key))
    self.game = game
    self.default_scores = []
    default_scores = meta_data.get('default-scores', [])
    for (i, s) in enumerate(default_scores):
        if (not isinstance(s, dict)):
            warning(('Default score must an array of objects for key "%s"' % key))
            continue
        user = s.get('user', None)
        if (user is None):
            email = s.get('email', None)
            if (email is None):
                warning(('Default score must contain user or email for key "%s"' % key))
                continue
            try:
                user = email.split('@', 1)[0]
                if user.startswith('no-reply+'):
                    user = user[9:]
            except AttributeError:
                warning(('Default score email "%s" must be a string for key "%s"' % (email, key)))
                continue
        if ('score' in s):
            try:
                score = float(s['score'])
                if (isinf(score) or isnan(score)):
                    warning(('Default score for user "%s" must be a number for key "%s"' % (user, key)))
                    continue
                user_score = UserScore(index, score, (time_now() - i))
                self.default_scores.append(user_score)
            except (ValueError, TypeError):
                warning(('Default score for user "%s" must be a number for key "%s"' % (user, key)))
                continue
        else:
            warning(('Default score for user "%s" missing score for key "%s"' % (user, key)))
            continue

dataset/ETHPy150Open turbulenz/turbulenz_local/turbulenz_local/models/apiv1/leaderboards.py Leaderboard.__init__/VarMisuse@691/1116 `user`->`index`