def _validate_event_name(self, event): if event == '' and self.event == '': msg = "You must specify an event name to show sets for a tournament" raise exceptions.ValidationError(msg) if event == '': event = self.event return event
def _validate_query_params(params, valid_params, route_type): """Validates query params for Smash.gg requests""" for param in params: if param not in valid_params: error_msg = """ '{0}' is not a valid query param for route of type: {1}. Valid types are [{2}]. """.format(param, route_type, ', '.join(valid_params)) raise exceptions.ValidationError(error_msg)
def sets_played_by_player(bracket_id, tag, filter_completed=False, filter_current=True, filter_future=True): try: tag = str(tag) tag = tag.lower() except: msg = "Given player tag is not and cannot be converted into a string" raise exceptions.ValidationError(msg) uri = BRACKET_URL + str(bracket_id) response = api.get(uri, VALID_BRACKET_PARAMS) return _filter_sets_given_player(response, tag, filter_completed, filter_current, filter_future)