Example #1
0
 def from_dict(d):
     """
     Convert dict representation to MatchSet
     :param d: dict representation of a MatchSet
     :return: MatchSet
     """
     matches = [Match.from_dict(m) for m in d['matches']]
     alpha = Document.from_json(d['alpha_doc'])
     beta = Document.from_json(d['beta_doc'])
     return MatchSet(alpha_doc=alpha,
                     beta_doc=beta,
                     matches=matches)
Example #2
0
    def load_from_database(self, data):
        """Load the tournament from database dictionary"""
        self.__id = data.doc_id
        self.name = data["name"]
        self.place = data["place"]
        self.date = data["date"]
        self.round_amount = data["round_amount"]
        self.description = data["description"]
        self.current_round = data["current_round"]
        self.ended = data["ended"]

        self.__init_players_from_indices(data["players"])

        self.matches = []
        i = 0
        for rnd in data["matches"]:
            self.matches.insert(i, [])
            for match in rnd:
                self.matches[i].insert(
                    len(self.matches[i]),
                    Match.from_dict(
                        self.__get_ply_from_id(match["upPlayer"]),
                        self.__get_ply_from_id(match["downPlayer"]), match))
            i += 1