def from_dict(obj: Any) -> 'Leaderboard': if not isinstance(obj, dict): return None goal = from_str(obj.get("goal")) num_ranked = from_int(obj.get("num_ranked")) rankings = from_list(Ranking.from_dict, obj.get("rankings")) return Leaderboard(goal, num_ranked, rankings)
def from_dict(obj: Any) -> 'Entrant': if not isinstance(obj, dict): return None user = User.from_dict(obj.get("user")) status = Status.from_dict(obj.get("status")) finish_time = from_union([from_timedelta, from_none], obj.get("finish_time")) finished_at = from_union([from_datetime, from_none], obj.get("finished_at")) place = from_union([from_int, from_none], obj.get("place")) place_ordinal = from_union([from_str, from_none], obj.get("place_ordinal")) score_change = from_union([from_int, from_none], obj.get("score_change")) comment = from_union([from_str, from_none], obj.get("comment")) has_comment = from_bool(obj.get("has_comment")) stream_live = from_bool(obj.get("stream_live")) stream_override = from_bool(obj.get("stream_override")) actions = from_list(from_str, obj.get("actions")) score = from_union([from_int, from_none], obj.get("score")) return Entrant(user=user, status=status, finish_time=finish_time, finished_at=finished_at, place=place, place_ordinal=place_ordinal, score_change=score_change, comment=comment, has_comment=has_comment, stream_live=stream_live, stream_override=stream_override, actions=actions, score=score)
def seasons_from_dict(s: Any) -> List[Season]: assert isinstance(s, List) if not s: return [] return from_union( [lambda x: from_list(Season.from_dict, x), from_none], s )
def from_dict(obj: Any) -> 'UserPastRaces': if not isinstance(obj, dict): return None count = from_int(obj.get("count")) num_pages = from_int(obj.get("num_pages")) races = from_list(Race.from_dict, obj.get("races")) return UserPastRaces(count, num_pages, races)
def flags_from_dict(s: Any) -> List[Flag]: assert isinstance(s, List) if not s: return [] return from_union( [lambda x: from_list(Flag.from_dict, x), from_none], s )
def racers_from_dict(s: Any) -> List[Racer]: assert isinstance(s, List) if not s: return [] return from_union( [lambda x: from_list(Racer.from_dict, x), from_none], s )
def schedule_from_dict(s: Any) -> List[ScheduleItem]: assert isinstance(s, List) if not s: return [] return from_union( [lambda x: from_list(ScheduleItem.from_dict, x), from_none], s )
def standings_from_dict(s: Any) -> List[Standings]: assert isinstance(s, List) if not s: return [] return from_union( [lambda x: from_list(Standings.from_dict, x), from_none], s )
def from_dict(obj: Any) -> 'Category': assert isinstance(obj, dict) name = from_str(obj.get("name")) short_name = from_str(obj.get("short_name")) slug = from_str(obj.get("slug")) url = from_str(obj.get("url")) data_url = from_str(obj.get("data_url")) image = from_str(obj.get("image")) info = from_str(obj.get("info")) streaming_required = from_bool(obj.get("streaming_required")) owners = from_list(User.from_dict, obj.get("owners")) moderators = from_list(User.from_dict, obj.get("moderators")) goals = from_list(from_str, obj.get("goals")) current_races = from_list( CurrentRace.from_dict, obj.get("current_races")) return Category( name=name, short_name=short_name, slug=slug, url=url, data_url=data_url, image=image, info=info, streaming_required=streaming_required, owners=owners, moderators=moderators, goals=goals, current_races=current_races )
def races_from_dict(s: Any) -> List[Race]: assert isinstance(s, dict) if not s.get("races"): return [] return from_union([lambda x: from_list(Race.from_dict, x), from_none], s.get("races"))
def from_dict(obj: Any) -> 'Race': if not isinstance(obj, dict): return None name = from_str(obj.get("name")) slug = from_str(obj.get("slug")) status = Status.from_dict(obj.get("status")) url = from_str(obj.get("url")) data_url = from_str(obj.get("data_url")) websocket_url = from_union([from_str, from_none], obj.get("websocket_url")) websocket_bot_url = from_union([from_str, from_none], obj.get("websocket_bot_url")) websocket_oauth_url = from_union([from_str, from_none], obj.get("websocket_oauth_url")) category = RaceCategory.from_dict(obj.get("category")) goal = Goal.from_dict(obj.get("goal")) info = from_str(obj.get("info")) entrants_count = from_int(obj.get("entrants_count")) entrants_count_inactive = from_int(obj.get("entrants_count_inactive")) entrants = from_union( [lambda x: from_list(Entrant.from_dict, x), from_none], obj.get("entrants")) opened_at = from_datetime(obj.get("opened_at")) start_delay = from_union([from_timedelta, from_none], obj.get("start_delay")) started_at = from_union([from_datetime, from_none], (obj.get("started_at"))) ended_at = from_union([from_datetime, from_none], (obj.get("ended_at"))) cancelled_at = from_union([from_datetime, from_none], (obj.get("cancelled_at"))) unlisted = from_union([from_bool, from_none], obj.get("unlisted")) time_limit = from_timedelta(obj.get("time_limit")) streaming_required = from_union([from_bool, from_none], obj.get("streaming_required")) auto_start = from_union([from_bool, from_none], obj.get("auto_start")) opened_by = from_union([lambda x: User.from_dict(x), from_none], obj.get("opened_by")) monitors = from_union( [lambda x: from_list(User.from_dict, x), from_none], obj.get("monitors")) recordable = from_union([from_bool, from_none], obj.get("recordable")) recorded = from_union([from_bool, from_none], obj.get("recorded")) recorded_by = from_union([lambda x: User.from_dict(x), from_none], obj.get("recorded_by")) allow_comments = from_union([from_bool, from_none], obj.get("allow_comments")) hide_comments = from_union([from_bool, from_none], obj.get("hide_comments")) allow_midrace_chat = from_union([from_bool, from_none], obj.get("allow_midrace_chat")) allow_non_entrant_chat = from_union([from_bool, from_none], obj.get("allow_non_entrant_chat")) chat_message_delay = from_union([from_str, from_none], obj.get("chat_message_delay")) version = from_union([from_int, from_none], obj.get("version")) entrants_count_finished = from_union( [from_int, from_none], obj.get("entrants_count_finished")) return Race(name=name, status=status, url=url, data_url=data_url, websocket_url=websocket_url, websocket_bot_url=websocket_bot_url, websocket_oauth_url=websocket_oauth_url, category=category, goal=goal, info=info, entrants_count=entrants_count, entrants_count_inactive=entrants_count_inactive, opened_at=opened_at, time_limit=time_limit, entrants=entrants, version=version, started_at=started_at, ended_at=ended_at, cancelled_at=cancelled_at, unlisted=unlisted, streaming_required=streaming_required, auto_start=auto_start, opened_by=opened_by, monitors=monitors, recordable=recordable, recorded=recorded, recorded_by=recorded_by, allow_comments=allow_comments, hide_comments=hide_comments, allow_midrace_chat=allow_midrace_chat, allow_non_entrant_chat=allow_non_entrant_chat, chat_message_delay=chat_message_delay, start_delay=start_delay, entrants_count_finished=entrants_count_finished, slug=slug)
def from_dict(obj: Any) -> 'UserSearch': if not isinstance(obj, dict): return None results = from_list(User.from_dict, obj.get("results")) return UserSearch(results)
def from_dict(obj: Any) -> 'Leaderboards': assert isinstance(obj, dict) leaderboards = from_list( Leaderboard.from_dict, obj.get("leaderboards")) return Leaderboards(leaderboards)