summaryrefslogtreecommitdiff
path: root/jfr_playoff/dto.py
diff options
context:
space:
mode:
Diffstat (limited to 'jfr_playoff/dto.py')
-rw-r--r--jfr_playoff/dto.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/jfr_playoff/dto.py b/jfr_playoff/dto.py
index a1b3a7f..a88cd2b 100644
--- a/jfr_playoff/dto.py
+++ b/jfr_playoff/dto.py
@@ -1,11 +1,18 @@
import sys
+def coalesce(*arg):
+ for el in arg:
+ if el is not None:
+ return el
+ return None
+
+
class Team(object):
name = ''
score = 0.0
def __unicode__(self):
- return u'%s (%.1f)' % (self.name, self.score)
+ return u'%s (%.1f)' % (coalesce(self.name, '<None>'), self.score)
def __repr__(self):
return unicode(self).encode(sys.stdin.encoding)
@@ -23,7 +30,7 @@ class Match(object):
def __repr__(self):
return (u'#%d (%s) %s [%s]' % (
- self.id, self.link, [unicode(team) for team in self.teams],
+ self.id, coalesce(self.link, '<None>'), [unicode(team) for team in self.teams],
u'finished' if self.running < 0 else (
u'%d boards' % self.running))
).encode(sys.stdin.encoding)
@@ -37,7 +44,7 @@ class Phase(object):
def __repr__(self):
return u'%s (%s) <%d matches> [%srunning]' % (
- self.title, self.link,
+ self.title, coalesce(self.link, '<None>'),
len(self.matches), '' if self.running else 'not ')
__all__ = ('Team', 'Match', 'Phase')