diff options
author | emkael <emkael@tlen.pl> | 2018-01-22 14:43:51 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2018-01-22 14:43:51 +0100 |
commit | 6fa172aed2f008ef601386387aaa2e149e64e0dd (patch) | |
tree | 91cd1057fb3f336455c0a5ee3af14a1d6f2c4b96 | |
parent | b2a504ceec511d601a0be10af08c5e98fbbfc481 (diff) |
Team list can now be retrieved from tournament standings
-rw-r--r-- | jfr_playoff/data.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/jfr_playoff/data.py b/jfr_playoff/data.py index 2c35191..f38cdee 100644 --- a/jfr_playoff/data.py +++ b/jfr_playoff/data.py @@ -1,3 +1,4 @@ +from cached_property import cached_property from urlparse import urljoin import mysql @@ -15,8 +16,8 @@ SWISS_TIE_WARNING = 'WARNING: tie detected in swiss %s.' + \ class PlayoffData(object): def __init__(self, settings): self.database = PlayoffDB(settings.get('database')) + self.team_settings = settings.get('teams') self.phases = settings.get('phases') - self.teams = settings.get('teams') self.swiss = [] if settings.has_section('swiss'): self.swiss = settings.get('swiss') @@ -24,6 +25,18 @@ class PlayoffData(object): self.match_info = {} self.leaderboard = [] + @cached_property + def teams(self): + if isinstance(self.team_settings, list): + return self.team_settings + db_teams = self.get_swiss_results( + self.team_settings['database'], + self.team_settings['ties'] if 'ties' in self.team_settings else []) + if 'final_positions' in self.team_settings: + for position in self.team_settings['final_positions']: + db_teams[position-1].append(position) + return db_teams + def generate_phases(self): self.grid = [] for phase in self.phases: |