summaryrefslogtreecommitdiff
path: root/jfr_playoff/dto.py
blob: a1b3a7fc0acc823ad54dd5136085eebed28903fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import sys

class Team(object):
    name = ''
    score = 0.0

    def __unicode__(self):
        return u'%s (%.1f)' % (self.name, self.score)

    def __repr__(self):
        return unicode(self).encode(sys.stdin.encoding)


class Match(object):
    id = None
    teams = None
    running = 0
    link = None
    winner = None
    loser = None
    winner_matches = None
    loser_matches = None

    def __repr__(self):
        return (u'#%d (%s) %s [%s]' % (
            self.id, self.link, [unicode(team) for team in self.teams],
            u'finished' if self.running < 0 else (
                u'%d boards' % self.running))
        ).encode(sys.stdin.encoding)


class Phase(object):
    title = None
    link = None
    matches = []
    running = False

    def __repr__(self):
        return u'%s (%s) <%d matches> [%srunning]' % (
            self.title, self.link,
            len(self.matches), '' if self.running else 'not ')

__all__ = ('Team', 'Match', 'Phase')