Exemplo n.º 1
0
    def _read_xml_plays(dom):
        rtn = PlaysXMLDataset()
        rtn.id = int(dom.attributes['id'].value)
        rtn.date = dom.attributes['date'].value
        rtn.quantity = int(dom.attributes['quantity'].value)
        rtn.length = int(dom.attributes['length'].value)
        rtn.incomplete = bool(int(dom.attributes['incomplete'].value))
        rtn.nowinstats = int(dom.attributes['nowinstats'].value)
        rtn.location = dom.attributes['location'].value

        items = dom.getElementsByTagName("item")
        for item in items:
            rtn.game_name = item.attributes['name'].value
            rtn.gameid = int(item.attributes['objectid'].value)

        return rtn
Exemplo n.º 2
0
        return PlayerXMLDataset(username=self.playerdataset.username,
                                userid=self.playerdataset.userid,
                                name=self.playerdataset.name,
                                startposition=self.startposition,
                                colour=self.colour,
                                score=float(self.score),
                                new=self.new,
                                rating=self.rating,
                                win=self.win)

    @xml.setter
    def xml(self, val):
        self.startposition = val.startposition
        self.colour = val.colour
        self.score = float(val.score)
        self.new = val.new
        self.rating = val.rating
        self.win = val.win
        self.playerdataset = PlayerDataset.query.filter_by(
            name=val.name).first()
        if self.playerdataset is None:
            self.playerdataset = PlayerDataset(xml=val)


if __name__ == "__main__":
    tmp = PlaysXMLDataset()
    tmp.gameid = 99
    tmp.game_name = "Hello World"

    data = GameDataset(xml=tmp)