summaryrefslogtreecommitdiff
path: root/jfr_playoff/generator.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-10-10 01:03:02 +0200
committeremkael <emkael@tlen.pl>2018-10-10 01:05:57 +0200
commit8181571f14486be1d81dde08e8c7a088241f9fb7 (patch)
tree210c230c3fef0519afb2bb289b863c4935b0b3c4 /jfr_playoff/generator.py
parent13e1272ad6daf785671270b38cccbff3afb91716 (diff)
Sorting eligible teams in front of predicted teams is now optional
Diffstat (limited to 'jfr_playoff/generator.py')
-rw-r--r--jfr_playoff/generator.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py
index 64bdeaa..c78d5cb 100644
--- a/jfr_playoff/generator.py
+++ b/jfr_playoff/generator.py
@@ -122,11 +122,11 @@ class PlayoffGenerator(object):
labels[l] = label_placeholder
# count how many teams are eligible (how many non-predicted teams are there)
known_teams = len(is_label_predicted) - sum(is_label_predicted)
- PlayoffLogger.get('generator').info('detected %d known teams, predicted mask: %s', known_teams, is_label_predicted)
- # sort labels to move eligible teams in front of predicted teams
- # TODO: should this be optional?
- labels = [label for i, label in enumerate(labels) if not is_label_predicted[i]] \
- + [label for i, label in enumerate(labels) if is_label_predicted[i]]
+ PlayoffLogger.get('generator').info('detected %d known team(s), predicted mask: %s', known_teams, is_label_predicted)
+ if self.team_box_settings.get('sort_eligible_first', True):
+ # sort labels to move eligible teams in front of predicted teams
+ labels = [label for i, label in enumerate(labels) if not is_label_predicted[i]] \
+ + [label for i, label in enumerate(labels) if is_label_predicted[i]]
PlayoffLogger.get('generator').info('team labels: %s', labels)
if len([label for label in labels if label is not None]):
# we have at least one known/predicted team
@@ -138,9 +138,14 @@ class PlayoffGenerator(object):
PlayoffLogger.get('generator').info('shortened team labels: %s', labels)
for l in range(0, len(labels)):
# concatenate labels, assigning appropriate classes to predicted teams
- team_label.append(self.__get_team_label(
- labels[l],
- 'MATCH_PREDICTED_TEAM_LABEL' if l >= known_teams else 'MATCH_TEAM_LABEL'))
+ if self.team_box_settings.get('sort_eligible_first', True):
+ team_label.append(self.__get_team_label(
+ labels[l],
+ 'MATCH_PREDICTED_TEAM_LABEL' if l >= known_teams else 'MATCH_TEAM_LABEL'))
+ else:
+ team_label.append(self.__get_team_label(
+ labels[l],
+ 'MATCH_PREDICTED_TEAM_LABEL' if is_label_predicted[l] else 'MATCH_TEAM_LABEL'))
# team names for tooltip
for name in team.name:
if name: