summaryrefslogtreecommitdiff
path: root/jfr_playoff/generator.py
diff options
context:
space:
mode:
authorMichał Zimniewicz <michzimny@users.noreply.github.com>2018-04-25 23:00:17 +0200
committerGitHub <noreply@github.com>2018-04-25 23:00:17 +0200
commitacebd78fc701d250069334d607fb918f6b666ba6 (patch)
treee15fce45511d2e0257bf4290baf4675d53745288 /jfr_playoff/generator.py
parent753085c46b30828092e66870f15763fee02b32f7 (diff)
parent1060632734b1f4e1117cbc33163101999ab201f6 (diff)
Merge pull request #24 from emkael/position-styles
Wyróżnienie wierszy tabeli klasyfikacji końcowej
Diffstat (limited to 'jfr_playoff/generator.py')
-rw-r--r--jfr_playoff/generator.py32
1 files changed, 27 insertions, 5 deletions
diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py
index cc4469d..2b5aaf0 100644
--- a/jfr_playoff/generator.py
+++ b/jfr_playoff/generator.py
@@ -11,8 +11,16 @@ class PlayoffGenerator(object):
self.canvas = {}
if settings.has_section('canvas'):
self.canvas = settings.get('canvas')
+ self.leaderboard_classes = {}
+ if settings.has_section('position_styles'):
+ self.leaderboard_classes = settings.get('position_styles')
def generate_content(self):
+ match_grid = self.get_match_grid(
+ self.data.get_dimensions(),
+ self.data.generate_phases(),
+ self.data.fill_match_info())
+ leaderboard_table = self.get_leaderboard_table()
return p_temp.PAGE % (
p_temp.PAGE_HEAD % (
p_temp.PAGE_HEAD_REFRESH % (
@@ -21,12 +29,10 @@ class PlayoffGenerator(object):
self.page['title']),
p_temp.PAGE_BODY % (
self.page['logoh'],
- self.get_match_grid(
- self.data.get_dimensions(),
- self.data.generate_phases(),
- self.data.fill_match_info()),
+ match_grid,
self.get_swiss_links(),
- self.get_leaderboard_table(),
+ leaderboard_table,
+ self.get_leaderboard_caption_table() if leaderboard_table else '',
p_temp.PAGE_BODY_FOOTER.decode('utf8') % (
datetime.now().strftime('%Y-%m-%d o %H:%M:%S'))))
@@ -119,6 +125,21 @@ class PlayoffGenerator(object):
grid_boxes
)
+ def get_leaderboard_row_class(self, position):
+ classes = []
+ for style in self.leaderboard_classes:
+ if position in style['positions']:
+ classes.append(style['class'])
+ return ' '.join(classes)
+
+ def get_leaderboard_caption_table(self):
+ rows = ''
+ for style in self.leaderboard_classes:
+ if 'caption' in style:
+ rows += p_temp.LEADERBOARD_CAPTION_TABLE_ROW % (
+ style['class'], style['caption'])
+ return p_temp.LEADERBOARD_CAPTION_TABLE % (rows) if rows else ''
+
def get_leaderboard_table(self):
leaderboard = self.data.fill_leaderboard()
if len([t for t in leaderboard if t is not None]) == 0:
@@ -127,6 +148,7 @@ class PlayoffGenerator(object):
rows = ''
for team in leaderboard:
rows += p_temp.LEADERBOARD_ROW % (
+ self.get_leaderboard_row_class(position),
position, self.get_flag(team), team or '')
position += 1
html = p_temp.LEADERBOARD.decode('utf8') % (rows)