summaryrefslogtreecommitdiff
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
parent13e1272ad6daf785671270b38cccbff3afb91716 (diff)
Sorting eligible teams in front of predicted teams is now optional
-rw-r--r--CONFIG.md1
-rw-r--r--jfr_playoff/generator.py21
2 files changed, 14 insertions, 8 deletions
diff --git a/CONFIG.md b/CONFIG.md
index f6d55c5..eec5ed1 100644
--- a/CONFIG.md
+++ b/CONFIG.md
@@ -33,6 +33,7 @@ Konfiguracja składa się, po kolei, z:
* `"label_ellipsis"` - ciąg wyświetlany na końcu skróconej etykiety teamów, gdy ustawienie `label_length_limit` ją skróciło (domyślnie `(...)`)
* `"name_separator"` - ciąg rozdzielający pełne nazwy teamów w etykiecie po najechaniu na skrócone nazwy w schemacie (domyślnie `<br />`)
* `"name_prefix"` - ciąg poprzedzający każdą pełną nazwę teamów w etykiecie po najechaniu (domyślnie wcięcie `&nbsp;&nbsp;`)
+ * `"sort_eligible_first"` - flaga włączająca wyświetlanie teamów zakwalifikowanych do danej fazy (tj. z zakończonym meczem bieżącej fazy) przed teamami z trwających meczów (domyślnie włączona)
- sekcji `"canvas"`: ustawień rysowania linii
+ `"winner_h_offset"`, `"winner_v_offset"` - marginesy (poziomy i pionowy) rysowania linii zwycięzców (odpowiednio: pionowych i poziomych, względem środka obszaru)
+ `"loser_h_offset"`, `"loser_v_offset"` - analogiczne marginesy rysowania linii przegranych
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: