From c8bf307f4a5782b84e0ba5b0f204f01dcbcee9e9 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 9 Aug 2018 00:51:55 +0200 Subject: Fixing parameters for swiss links --- jfr_playoff/generator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'jfr_playoff') diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index 22bdc82..c4a053e 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -197,7 +197,8 @@ class PlayoffGenerator(object): event_label = self.p_temp.get('SWISS_DEFAULT_LABEL', event['position']) if 'label' in event and event['label'] is not None: event_label = event['label'] - info.append((self.p_temp.get('SWISS_LINK') \ + info.append((self.p_temp.get('SWISS_LINK', + event['link'], event_label) \ if event['finished'] \ else self.p_temp.get( 'SWISS_RUNNING_LINK', -- cgit v1.2.3 From 9a42b9f29d4b51f6e777cea0dc2bd750d102fa13 Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 9 Aug 2018 10:26:51 +0200 Subject: Shortening long (multiple) team labels --- jfr_playoff/generator.py | 1 + 1 file changed, 1 insertion(+) (limited to 'jfr_playoff') diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index 59c83a6..66e9a01 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -57,6 +57,7 @@ class PlayoffGenerator(object): team_label = ' / '.join([ self.data.get_shortname(name) for name in team.name.split('
')]) + team_label = team_label[:30] + (team_label[30:] and '(...)') team_html = self.p_temp.get( 'MATCH_TEAM_LINK', match.link, team.name, team_label) \ -- cgit v1.2.3 From 2b906f5038565f718e589cd70c24f4614fd0f4cf Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 9 Aug 2018 20:17:08 +0200 Subject: Scores and team names for single-segment matches --- jfr_playoff/matchinfo.py | 52 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 14 deletions(-) (limited to 'jfr_playoff') diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py index 93b997a..2aeb2c1 100644 --- a/jfr_playoff/matchinfo.py +++ b/jfr_playoff/matchinfo.py @@ -110,11 +110,31 @@ class MatchInfo: row = self.__find_table_row(self.info.link) if row is None: raise ValueError('table row not found') - score_cell = row.select('td.bdc')[-1] - scores = [ - float(text) for text - in score_cell.contents - if isinstance(text, unicode)] + try: + scores = [ + float(text) for text + in row.select('td.bdc')[-1].contents + if isinstance(text, unicode)] + except ValueError: + try: + # running single-segment + scores = [ + float(text.strip()) for text + in row.select('td.bdcg a')[-1].contents + if isinstance(text, unicode)] + except IndexError: + # static single-segment + scores = [ + float(text.strip()) for text + in row.select('td.bdc a')[-1].contents + if isinstance(text, unicode)] + # carry-over + carry_over = [ + float(text.strip()) if len(text.strip()) > 0 else 0.0 for text + in row.select('td.bdc')[0].contents + if isinstance(text, unicode)] + for i in range(0, 2): + scores[i] += carry_over[i] team_names = [[text for text in link.contents if isinstance(text, unicode)][0].strip(u'\xa0') for link in row.select('a[onmouseover]')] @@ -247,17 +267,21 @@ class MatchInfo: row = self.__find_table_row(self.info.link) if row is None: raise ValueError('table row not found') - cells = row.select('td.bdc') - segments = [cell for cell in cells if self.__has_segment_link(cell)] - towels = [cell for cell in cells if self.__has_towel_image(cell)] - if len(segments) == 0: - if len(towels) > 0: - PlayoffLogger.get('matchinfo').info( - 'HTML board count for match #%d: all towels', self.info.id) - return 1, 1 # entire match is toweled, so mark as finished + for selector in ['td.bdc', 'td.bdcg']: + cells = row.select(selector) + segments = [cell for cell in cells if self.__has_segment_link(cell)] + towels = [cell for cell in cells if self.__has_towel_image(cell)] + if len(segments) == 0: + if len(towels) > 0: + PlayoffLogger.get('matchinfo').info( + 'HTML board count for match #%d: all towels', self.info.id) + return 1, 1 # entire match is toweled, so mark as finished else: - raise ValueError('segments not found') + break + if len(segments) == 0: + raise ValueError('segments not found') running_segments = row.select('td.bdca') + # FIXME: running single-segment match board count running_boards = sum([self.__get_html_running_boards(segment) for segment in running_segments]) finished_segments = [] boards_in_segment = None -- cgit v1.2.3