diff options
author | emkael <emkael@tlen.pl> | 2018-09-28 17:45:52 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2018-09-28 17:48:32 +0200 |
commit | 17b67eec50d428383406d4309bc7506fd22015db (patch) | |
tree | f194fe8ebdfc012daf54ed04b80e40f65ecf6c55 /jfr_playoff | |
parent | 1e17305d838189d9e4e8f861f9c67fa736a0ba11 (diff) |
Refactoring fetching default values for config dictionariesposition-boxes
Diffstat (limited to 'jfr_playoff')
-rw-r--r-- | jfr_playoff/generator.py | 9 | ||||
-rw-r--r-- | jfr_playoff/matchinfo.py | 8 |
2 files changed, 7 insertions, 10 deletions
diff --git a/jfr_playoff/generator.py b/jfr_playoff/generator.py index 19b8c1d..c2fba28 100644 --- a/jfr_playoff/generator.py +++ b/jfr_playoff/generator.py @@ -117,8 +117,7 @@ class PlayoffGenerator(object): ] if match.loser_matches is not None else [] place_loser_link = [] place_winner_link = [] - if 'starting_position_indicators' in self.page \ - and self.page['starting_position_indicators']: + if self.page.get('starting_position_indicators', None): for team in match.teams: if len(team.place) > 0: place_link = ['place-' + str(pl) for pl in team.place] @@ -193,8 +192,7 @@ class PlayoffGenerator(object): finishing_places = set() for phase in grid: grid_x = col_no * self.page['width'] + (col_no + 1) * self.page['margin'] \ - if 'starting_position_indicators' in self.page \ - and self.page['starting_position_indicators'] \ + if self.page.get('starting_position_indicators', None) \ else col_no * (self.page['width'] + self.page['margin']) grid_boxes += self.get_phase_header(phase, grid_x) match_height = canvas_size[1] / len(phase.matches) @@ -206,8 +204,7 @@ class PlayoffGenerator(object): PlayoffLogger.get('generator').info( 'calculated grid box (%d, %d) position: (%d, %d)', col_no, row_no, grid_x, grid_y) - if 'box_positioning' in self.canvas \ - and str(match) in self.canvas['box_positioning']: + if str(match) in self.canvas.get('box_positioning', {}): if isinstance(self.canvas['box_positioning'][str(match)], list): grid_x, grid_y = self.canvas['box_positioning'][str(match)][0:2] else: diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py index 4089a76..3e4d913 100644 --- a/jfr_playoff/matchinfo.py +++ b/jfr_playoff/matchinfo.py @@ -32,8 +32,8 @@ class MatchInfo: self.info.loser_matches += self.config['teams'][i]['loser'] self.info.winner_matches = list(set(self.info.winner_matches)) self.info.loser_matches = list(set(self.info.loser_matches)) - self.info.winner_place = self.config['winner'] if 'winner' in self.config else [] - self.info.loser_place = self.config['loser'] if 'loser' in self.config else [] + self.info.winner_place = self.config.get('winner', []) + self.info.loser_place = self.config.get('loser', []) self.info.teams = [] def __fetch_match_link(self): @@ -215,8 +215,8 @@ class MatchInfo: self.info.id, type(e).__name__, str(e)) self.info.teams = self.__get_config_teams(self.info.teams) for team in range(0, len(self.info.teams)): - if 'place' in self.config['teams'][team]: - self.info.teams[team].place = self.config['teams'][team]['place'] + self.info.teams[team].place = self.config['teams'][team].get( + 'place', self.info.teams[team].place) def __get_db_board_count(self): |