Example #1
0
 def from_dict(obj: dict) -> 'Battlefy':
     assert isinstance(obj, dict)
     return Battlefy(
         slugs=from_list(lambda x: BattlefyUserSocial.from_dict(x), obj.get("Slugs")),
         usernames=from_list(lambda x: Name.from_dict(x), obj.get("Usernames")),
         persistent_ids=from_list(lambda x: Name.from_dict(x), obj.get("PersistentIds"))
     )
Example #2
0
 def from_dict(obj: dict) -> 'Bracket':
     assert isinstance(obj, dict)
     return Bracket(
         name=obj.get("Name", UNKNOWN_BRACKET),
         matches=from_list(lambda x: Game.from_dict(x), obj.get("Matches")),
         placements=Placement.from_dict(obj.get("Placements")) if "Placements" in obj else None
     )
Example #3
0
File: team.py Project: kjhf/SlappPy
 def from_dict(obj: dict) -> 'Team':
     assert isinstance(obj, dict)
     from slapp_py.core_classes.source import Source
     return Team(battlefy_persistent_team_ids=from_list(
         lambda x: BattlefyTeamSocial.from_dict(x),
         obj.get("BattlefyPersistentTeamIds")),
                 clan_tags=from_list(lambda x: ClanTag.from_dict(x),
                                     obj.get("ClanTags")),
                 divisions=from_list(lambda x: Division.from_dict(x),
                                     obj.get("Divisions")),
                 names=from_list(lambda x: Name.from_dict(x),
                                 obj.get("Names")),
                 sources=Source.deserialize_source_uuids(obj),
                 twitter_profiles=from_list(lambda x: Twitter.from_dict(x),
                                            obj.get("Twitter")),
                 guid=UUID(obj.get("Id")))
Example #4
0
 def from_dict(obj: dict) -> 'Source':
     assert isinstance(obj, dict)
     try:
         return Source(
             guid=UUID(obj.get("Id")),
             name=obj.get("Name", UNKNOWN_SOURCE),
             brackets=from_list(lambda x: Bracket.from_dict(x),
                                obj.get("Brackets")),
             players=from_list(lambda x: Player.from_dict(x),
                               obj.get("Players")),
             teams=from_list(lambda x: Team.from_dict(x), obj.get("Teams")),
             uris=from_list(lambda x: str(x), obj.get("Uris")),
             start=Source.cs_ticks_to_datetime(obj["Start"])
             if "Start" in obj else UNKNOWN_DATE_TIME,
         )
     except Exception as e:
         print(
             f"Exception occurred loading Source with id {obj.get('Id', '(Unknown)')}: {e}, {e.args}"
         )
         raise e
Example #5
0
 def from_dict(obj: dict) -> 'Player':
     assert isinstance(obj, dict)
     from slapp_py.core_classes.source import Source
     return Player(battlefy=Battlefy.from_dict(obj.get("Battlefy"))
                   if "Battlefy" in obj else None,
                   discord=Discord.from_dict(obj.get("Discord"))
                   if "Discord" in obj else None,
                   friend_codes=from_list(lambda x: FriendCode.from_dict(x),
                                          obj.get("FriendCode")),
                   names=from_list(lambda x: Name.from_dict(x),
                                   obj.get("Names")),
                   sendou_profiles=from_list(lambda x: Sendou.from_dict(x),
                                             obj.get("Sendou")),
                   skill=Skill.from_dict(obj.get("Skill"))
                   if "Skill" in obj else Skill(),
                   sources=Source.deserialize_source_uuids(obj),
                   teams=deserialize_uuids(obj, "Teams"),
                   twitch_profiles=from_list(lambda x: Twitch.from_dict(x),
                                             obj.get("Twitch")),
                   twitter_profiles=from_list(
                       lambda x: Twitter.from_dict(x), obj.get("Twitter")),
                   weapons=from_list(lambda x: str(x), obj.get("Weapons")),
                   country=obj.get("Country", None),
                   top500=obj.get("Top500", False),
                   guid=UUID(obj.get("Id")))
Example #6
0
 def from_dict(obj: dict) -> 'Score':
     assert isinstance(obj, dict)
     return Score(points=from_list(lambda x: int(x), obj.get("Points")))
Example #7
0
 def from_dict(obj: dict) -> 'FriendCode':
     assert isinstance(obj, dict)
     return FriendCode(param=from_list(lambda x: int(x), obj.get("FC")))
Example #8
0
 def from_dict(obj: dict) -> 'Discord':
     assert isinstance(obj, dict)
     return Discord(ids=from_list(lambda x: Name.from_dict(x),
                                  obj.get("Ids")),
                    usernames=from_list(lambda x: Name.from_dict(x),
                                        obj.get("Usernames")))