From 008b5ba8af443f337db3e79b4495a1d8275fe201 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 28 Sep 2018 01:17:59 +0200 Subject: Adding changelog information, for clarity --- BRANCHES.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 BRANCHES.txt diff --git a/BRANCHES.txt b/BRANCHES.txt new file mode 100644 index 0000000..c752345 --- /dev/null +++ b/BRANCHES.txt @@ -0,0 +1,25 @@ +Względem ostatniego sezonu + +[master] [v1.1.2]: + - oznaczenia (style) w tabeli końcowej + +[bugfixes]: + - poprawki wymiarów (całego obszaru rysowania oraz odstępów między obszarami poszczególnych meczów) + +[i18n]: + - nowy silnik szablonów + - tłumaczenia + +[devel]: + - [i18n] + - [bugfixes] + - obszerne logowanie + - poprawki z Sopotu: + + bugfix dla linków do swissów + + skracanie wyświetlania długich nazw teamów (> 30 znaków, TODO: parametryzacja długości) + + obsługa meczów jednosegmentowych + +[position-boxes]: + - [devel] + - możliwość wyświetlania elementów grafu dla pozycji początkowych i pozycji końcowych + - możliwość dowolnego pozycjonowania meczów (zarówno w pionie w ramach fazy, jak i o zupełnie dowolnych współrzędnych) -- cgit v1.2.3 From 7a90aa51e77e201b51e8a9270c5e5da28cc3566f Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 28 Sep 2018 01:24:09 +0200 Subject: Tracking merges and change information, for clarity --- BRANCHES.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/BRANCHES.txt b/BRANCHES.txt index c752345..653003d 100644 --- a/BRANCHES.txt +++ b/BRANCHES.txt @@ -13,9 +13,8 @@ Względem ostatniego sezonu [devel]: - [i18n] - [bugfixes] - - obszerne logowanie + - obszerne komunikaty diagnostyczne - poprawki z Sopotu: - + bugfix dla linków do swissów + skracanie wyświetlania długich nazw teamów (> 30 znaków, TODO: parametryzacja długości) + obsługa meczów jednosegmentowych -- cgit v1.2.3 From 714a198c3cd4f0975c57010b3888d98057e6bb7c Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 28 Sep 2018 12:32:36 +0200 Subject: Customize label character limit Fixes #27 --- CONFIG.md | 1 + jfr_playoff/generator.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CONFIG.md b/CONFIG.md index 906081f..3a26f81 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -25,6 +25,7 @@ Konfiguracja składa się, po kolei, z: + `"refresh"` - parametr odświeżania strony drabinki: `0` = wyłączone, liczba naturalna = interwał odświeżania, w sekundach + `"width"` i `"height"` - wymiary (w pikselach) miejsca rezerwowanego dla każdego meczu w widoku drabinki (`"width"` bezpośrednio wpływa na rozmieszczanie kolumn, wewnątrz każdej z kolumn mecze rozmieszczane są równomiernie, w zależnie od ich liczby) + `"margin"` - odstęp między w/w miejscem (minimalny - jak widać, w przypadku mniejszej liczby meczów w fazie, odstępy się dopasują) + + `"label_length_limit"` - maksymalna liczba znaków wyświetlanych jako skrócona nazwa drużyn(y) w schemacie (`0` lub brak wartości oznacza brak limitu) - 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 66e9a01..5dfed13 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -57,7 +57,10 @@ 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 '(...)') + label_max_length = self.page['label_length_limit'] \ + if 'label_length_limit' in self.page else 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) \ -- cgit v1.2.3 From 528bbb28fafdef9aa107149fa5f2a90dccfa00f9 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 28 Sep 2018 14:30:19 +0200 Subject: Comments on the code for single-segment match team/score fetching --- jfr_playoff/matchinfo.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py index 2aeb2c1..b40d6d1 100644 --- a/jfr_playoff/matchinfo.py +++ b/jfr_playoff/matchinfo.py @@ -116,6 +116,7 @@ class MatchInfo: in row.select('td.bdc')[-1].contents if isinstance(text, unicode)] except ValueError: + # single-segment match try: # running single-segment scores = [ @@ -272,11 +273,14 @@ class MatchInfo: 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: + # in single-segment match, there are no td.bdc cells with segment links + # but maybe it's a multi-segment match with towels 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: + # not a single-segment match, no need to look for td.bdcg cells break if len(segments) == 0: raise ValueError('segments not found') -- cgit v1.2.3 From b1ce81da1478715b1d3a8dd6883c5655db0a8f68 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 28 Sep 2018 14:30:55 +0200 Subject: Fixing score fetch for a single-segment match with a towel --- jfr_playoff/matchinfo.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py index b40d6d1..f726282 100644 --- a/jfr_playoff/matchinfo.py +++ b/jfr_playoff/matchinfo.py @@ -124,11 +124,15 @@ class MatchInfo: 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)] + try: + # static single-segment + scores = [ + float(text.strip()) for text + in row.select('td.bdc a')[-1].contents + if isinstance(text, unicode)] + except IndexError: + # toweled single-segment + scores = [0.0, 0.0] # carry-over carry_over = [ float(text.strip()) if len(text.strip()) > 0 else 0.0 for text -- cgit v1.2.3 From cb1edf3fb102f347adde2a1c8aec205c24cd36be Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 28 Sep 2018 14:31:35 +0200 Subject: Fixing carry-over fetch for a single-segment match if there's none --- jfr_playoff/matchinfo.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py index f726282..d968a34 100644 --- a/jfr_playoff/matchinfo.py +++ b/jfr_playoff/matchinfo.py @@ -138,6 +138,9 @@ class MatchInfo: float(text.strip()) if len(text.strip()) > 0 else 0.0 for text in row.select('td.bdc')[0].contents if isinstance(text, unicode)] + if len(carry_over) < 2: + # no carry-over, possibly no carry-over cells or empty + carry_over = [0.0, 0.0] for i in range(0, 2): scores[i] += carry_over[i] team_names = [[text for text in link.contents -- cgit v1.2.3 From e23ef3b9dc245d134e4b0105e2dca7a1833f1ba5 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 28 Sep 2018 14:32:23 +0200 Subject: Fixing overall bourd count fetch for a single-segment match --- jfr_playoff/matchinfo.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py index d968a34..900c210 100644 --- a/jfr_playoff/matchinfo.py +++ b/jfr_playoff/matchinfo.py @@ -292,7 +292,6 @@ class MatchInfo: 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 @@ -303,10 +302,14 @@ class MatchInfo: finished_segments.append(segment) if boards_in_segment is None and boards > 0: boards_in_segment = boards - PlayoffLogger.get('matchinfo').info( - 'HTML board count for match #%d, found: %d finished segments, %d towels, %d boards per segment and %d boards in running segment', - self.info.id, len(finished_segments), len(towels), boards_in_segment, running_boards) - total_boards = (len(segments) + len(towels) + len(running_segments)) * boards_in_segment + if 'bdcg' in segments[0]['class']: + # only a single-segment match will yield td.bdcg cells with segment scores + total_boards = boards_in_segment + else: + PlayoffLogger.get('matchinfo').info( + 'HTML board count for match #%d, found: %d finished segments, %d towels, %d boards per segment and %d boards in running segment', + self.info.id, len(finished_segments), len(towels), boards_in_segment, running_boards) + total_boards = (len(segments) + len(towels) + len(running_segments)) * boards_in_segment played_boards = (len(towels) + len(finished_segments)) * boards_in_segment + running_boards PlayoffLogger.get('matchinfo').info( 'HTML board count for match #%d: %d/%d', -- cgit v1.2.3 From 1ab6233374e1c25e3f9f58db98b547125cbef452 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 28 Sep 2018 15:46:28 +0200 Subject: Revert running segment link if there are no scores in the segment (possibly "Don't send scores") Part of #7 is implented by this change --- jfr_playoff/matchinfo.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py index 900c210..dd2ee30 100644 --- a/jfr_playoff/matchinfo.py +++ b/jfr_playoff/matchinfo.py @@ -245,6 +245,15 @@ class MatchInfo: def __get_html_running_boards(self, cell): return int(cell.contents[-1].strip()) + def __get_html_segment_board_count(self, segment_url): + segment_content = p_remote.fetch(segment_url) + board_rows = [row for row in segment_content.find_all('tr') if len(row.select('td.bdcc a.zb')) > 0] + board_count = len(board_rows) + played_boards = len([ + row for row in board_rows if len( + ''.join([cell.text.strip() for cell in row.select('td.bdc')])) > 0]) + return played_boards, board_count + def __get_finished_info(self, cell): segment_link = cell.select('a[href]') if len(segment_link) > 0: @@ -252,12 +261,7 @@ class MatchInfo: r'\.htm$', '.html', urljoin(self.info.link, segment_link[0]['href'])) try: - segment_content = p_remote.fetch(segment_url) - board_rows = [row for row in segment_content.find_all('tr') if len(row.select('td.bdcc a.zb')) > 0] - board_count = len(board_rows) - played_boards = len([ - row for row in board_rows if len( - ''.join([cell.text.strip() for cell in row.select('td.bdc')])) > 0]) + played_boards, board_count = self.__get_html_segment_board_count(segment_url) PlayoffLogger.get('matchinfo').info( 'HTML played boards count for segment: %d/%d', played_boards, board_count) @@ -373,6 +377,7 @@ class MatchInfo: def __determine_running_link(self): if self.info.link is None: return + match_link = self.info.link link_match = re.match(r'^(.*)runda(\d+)\.html$', self.info.link) if link_match: try: @@ -390,6 +395,21 @@ class MatchInfo: PlayoffLogger.get('matchinfo').warning( 'cannot determine running link from HTML for match #%d: %s(%s)', self.info.id, type(e).__name__, str(e)) + if self.info.link != match_link: + # we've detected a running segment link + # we should check if the segment's uploaded live + try: + boards_played, board_count = self.__get_html_segment_board_count(re.sub('\.htm$', '.html', self.info.link)) + except IOError as e: + PlayoffLogger.get('matchinfo').warning( + 'cannot determine running link (%s) board count for match #%d: %s(%s)', + self.info.link, self.info.id, type(e).__name__, str(e)) + boards_played = 0 + if not boards_played: + PlayoffLogger.get('matchinfo').warning( + 'running link (%s) for match #%d is not live, reverting to match link (%s)', + self.info.link, self.info.id, match_link) + self.info.link = match_link def set_phase_link(self, phase_link): if self.info.link is None: -- cgit v1.2.3 From fe41a61c97e558abec388bab81c041ae562fce37 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 28 Sep 2018 15:52:02 +0200 Subject: Debug information on remote URL fetch --- jfr_playoff/remote.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jfr_playoff/remote.py b/jfr_playoff/remote.py index 2deb7ce..f0bf6c2 100644 --- a/jfr_playoff/remote.py +++ b/jfr_playoff/remote.py @@ -21,4 +21,7 @@ class RemoteUrl: if encoding_match: request.encoding = encoding_match.group(2) cls.url_cache[url] = request.text + PlayoffLogger.get('remote').info( + 'fetched %d bytes from remote location', + len(cls.url_cache[url])) return bs(cls.url_cache[url], 'lxml') -- cgit v1.2.3 From f01a522694aad85c857470b9a8630c6194a38d36 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 28 Sep 2018 15:52:25 +0200 Subject: Additional info on features since last merge --- BRANCHES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/BRANCHES.txt b/BRANCHES.txt index 653003d..5eb0252 100644 --- a/BRANCHES.txt +++ b/BRANCHES.txt @@ -17,6 +17,7 @@ Względem ostatniego sezonu - poprawki z Sopotu: + skracanie wyświetlania długich nazw teamów (> 30 znaków, TODO: parametryzacja długości) + obsługa meczów jednosegmentowych + - nielinkowanie do segmentów, które nie wysyłają wyników na żywo [position-boxes]: - [devel] -- cgit v1.2.3