diff options
author | emkael <emkael@tlen.pl> | 2019-12-30 12:34:48 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-12-30 12:34:48 +0100 |
commit | f77bac9b5406c6bf6b1c819f155164568ef4af36 (patch) | |
tree | 972f2851f7ebe76842ff668bce0002ed961a43fe /jfr_playoff/data.py | |
parent | 5a5326bf17a4ed3402255493efefd69544afe0d0 (diff) |
Preparing result info class refactoring
Diffstat (limited to 'jfr_playoff/data.py')
-rw-r--r-- | jfr_playoff/data.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/jfr_playoff/data.py b/jfr_playoff/data.py index 6649e68..132ee02 100644 --- a/jfr_playoff/data.py +++ b/jfr_playoff/data.py @@ -1,10 +1,40 @@ +from jfr_playoff.logger import PlayoffLogger + + +class ResultInfo(object): + def __init__(self, *args): + self.clients = self.fill_client_list(*args) + + def fill_client_list(self, settings, database): + return [] + + def call_client(self, method, default, *args): + PlayoffLogger.get('resultinfo').info( + 'calling %s on result info clients', method) + for client in self.clients: + try: + ret = getattr(client, method)(*args) + PlayoffLogger.get('resultinfo').info( + '%s method returned %s', method, ret) + return ret + except Exception as e: + if type(e) in client.get_exceptions(method): + PlayoffLogger.get('resultinfo').warning( + '%s method raised %s(%s)', + method, type(e).__name__, str(e)) + else: + raise + PlayoffLogger.get('resultinfo').info( + '%s method returning default: %s', method, default) + return default + + from cached_property import cached_property from jfr_playoff.db import PlayoffDB from jfr_playoff.dto import Phase from jfr_playoff.matchinfo import MatchInfo from jfr_playoff.tournamentinfo import TournamentInfo -from jfr_playoff.logger import PlayoffLogger class PlayoffData(object): |