summaryrefslogtreecommitdiff
path: root/jfr_playoff
diff options
context:
space:
mode:
Diffstat (limited to 'jfr_playoff')
-rw-r--r--jfr_playoff/dto.py5
-rw-r--r--jfr_playoff/generator.py12
-rw-r--r--jfr_playoff/matchinfo.py37
3 files changed, 29 insertions, 25 deletions
diff --git a/jfr_playoff/dto.py b/jfr_playoff/dto.py
index a88cd2b..ad70735 100644
--- a/jfr_playoff/dto.py
+++ b/jfr_playoff/dto.py
@@ -8,9 +8,12 @@ def coalesce(*arg):
class Team(object):
- name = ''
+ name = None
score = 0.0
+ def __init__(self):
+ self.name = []
+
def __unicode__(self):
return u'%s (%.1f)' % (coalesce(self.name, '<None>'), self.score)
diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py
index d358d86..a1b519e 100644
--- a/jfr_playoff/generator.py
+++ b/jfr_playoff/generator.py
@@ -55,23 +55,23 @@ class PlayoffGenerator(object):
for team in match.teams:
score_html = self.p_temp.get('MATCH_SCORE', team.score)
team_label = ' / '.join([
- self.data.get_shortname(name) for name in
- team.name.split('<br />')])
+ self.data.get_shortname(name) for name in team.name])
+ team_name = '<br />'.join(team.name)
label_max_length = self.page.get('label_length_limit', 0)
if label_max_length:
team_label = team_label[:label_max_length] + (team_label[label_max_length:] and '(...)')
team_html = self.p_temp.get(
'MATCH_TEAM_LINK',
- match.link, team.name, team_label) \
+ match.link, team_name, team_label) \
if match.link is not None \
else self.p_temp.get(
'MATCH_TEAM_NON_LINK',
- team.name, team_label)
+ team_name, team_label)
rows += self.p_temp.get(
'MATCH_TEAM_ROW',
' '.join([
- 'winner' if team.name == match.winner else '',
- 'loser' if team.name == match.loser else ''
+ 'winner' if match.winner in team.name else '',
+ 'loser' if match.loser in team.name else ''
]).strip(),
team_html,
self.p_temp.get(
diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py
index ab742d4..e9854c5 100644
--- a/jfr_playoff/matchinfo.py
+++ b/jfr_playoff/matchinfo.py
@@ -58,9 +58,9 @@ class MatchInfo:
teams[i].score = self.config['score'][score]
try:
team_no = int(score)
- teams[i].name = self.teams[team_no-1][0]
+ teams[i].name = [self.teams[team_no-1][0]]
except ValueError:
- teams[i].name = score
+ teams[i].name = [score]
teams_fetched = True
else:
teams[i].score = score
@@ -77,8 +77,8 @@ class MatchInfo:
row = self.database.fetch(
self.config['database'], p_sql.MATCH_RESULTS,
(self.config['table'], self.config['round']))
- teams[0].name = row[0]
- teams[1].name = row[1]
+ teams[0].name = [row[0]]
+ teams[1].name = [row[1]]
if fetch_scores:
teams[0].score = row[3] + row[5]
teams[1].score = row[4] + row[6]
@@ -147,7 +147,7 @@ class MatchInfo:
if isinstance(text, unicode)][0].strip(u'\xa0')
for link in row.select('a[onmouseover]')]
for i in range(0, 2):
- teams[i].name = team_names[i]
+ teams[i].name = [team_names[i]]
teams[i].score = scores[i]
PlayoffLogger.get('matchinfo').info(
'HTML scores for match #%d: %s',
@@ -158,9 +158,9 @@ class MatchInfo:
for i in range(0, 2):
match_teams = []
if isinstance(self.config['teams'][i], basestring):
- teams[i].name = self.config['teams'][i]
+ teams[i].name = [self.config['teams'][i]]
elif isinstance(self.config['teams'][i], list):
- teams[i].name = '<br />'.join(self.config['teams'][i])
+ teams[i].name = self.config['teams'][i]
else:
if 'winner' in self.config['teams'][i]:
match_teams += [
@@ -176,11 +176,10 @@ class MatchInfo:
for place in self.config['teams'][i]['place']]
known_teams = [team for team in match_teams if team is not None]
if len(known_teams) > 0:
- teams[i].name = '<br />'.join([
- team if team is not None
- else '??' for team in match_teams])
+ teams[i].name = [team if team is not None
+ else '??' for team in match_teams]
else:
- teams[i].name = ''
+ teams[i].name = ['']
PlayoffLogger.get('matchinfo').info(
'config scores for match #%d: %s',
self.info.id, teams)
@@ -341,13 +340,15 @@ class MatchInfo:
else boards_played
def __determine_outcome(self):
- if (self.info.running == -1):
- if self.info.teams[0].score > self.info.teams[1].score:
- self.info.winner = self.info.teams[0].name
- self.info.loser = self.info.teams[1].name
- else:
- self.info.loser = self.info.teams[0].name
- self.info.winner = self.info.teams[1].name
+ if (len(self.info.teams[0].name) == 1) \
+ and (len(self.info.teams[1].name) == 1):
+ if self.info.running == -1:
+ if self.info.teams[0].score > self.info.teams[1].score:
+ self.info.winner = self.info.teams[0].name[0]
+ self.info.loser = self.info.teams[1].name[0]
+ else:
+ self.info.loser = self.info.teams[0].name[0]
+ self.info.winner = self.info.teams[1].name[0]
def __get_db_running_link(self, prefix, round_no):
current_segment = int(