summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2019-12-30 12:49:54 +0100
committeremkael <emkael@tlen.pl>2019-12-30 12:49:54 +0100
commit7a598f65372b1b694d222946fd6269033bde0e54 (patch)
treee33fb74aad63756f0b3c94f12e29aff6c97064ed
parentf77bac9b5406c6bf6b1c819f155164568ef4af36 (diff)
New package structure for result info classes
-rw-r--r--jfr_playoff/data/__init__.py (renamed from jfr_playoff/data.py)34
-rw-r--r--jfr_playoff/data/info.py29
-rw-r--r--jfr_playoff/data/tournament/__init__.py (renamed from jfr_playoff/tournamentinfo/__init__.py)8
-rw-r--r--jfr_playoff/data/tournament/jfrdb.py (renamed from jfr_playoff/tournamentinfo/jfrdb.py)2
-rw-r--r--jfr_playoff/data/tournament/jfrhtml.py (renamed from jfr_playoff/tournamentinfo/jfrhtml.py)2
-rw-r--r--jfr_playoff/data/tournament/tcjson.py (renamed from jfr_playoff/tournamentinfo/tcjson.py)2
-rw-r--r--jfr_playoff/matchinfo.py5
7 files changed, 41 insertions, 41 deletions
diff --git a/jfr_playoff/data.py b/jfr_playoff/data/__init__.py
index 132ee02..494eaef 100644
--- a/jfr_playoff/data.py
+++ b/jfr_playoff/data/__init__.py
@@ -1,40 +1,10 @@
-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.data.tournament import TournamentInfo
+from jfr_playoff.logger import PlayoffLogger
class PlayoffData(object):
diff --git a/jfr_playoff/data/info.py b/jfr_playoff/data/info.py
new file mode 100644
index 0000000..371ac6a
--- /dev/null
+++ b/jfr_playoff/data/info.py
@@ -0,0 +1,29 @@
+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
diff --git a/jfr_playoff/tournamentinfo/__init__.py b/jfr_playoff/data/tournament/__init__.py
index 21cd62a..e86d294 100644
--- a/jfr_playoff/tournamentinfo/__init__.py
+++ b/jfr_playoff/data/tournament/__init__.py
@@ -1,5 +1,5 @@
from jfr_playoff.logger import PlayoffLogger
-from jfr_playoff.data import ResultInfo
+from jfr_playoff.data.info import ResultInfo
class TournamentInfoClient(object):
@@ -27,9 +27,9 @@ class TournamentInfo(ResultInfo):
def fill_client_list(self, settings, database):
clients = []
- from jfr_playoff.tournamentinfo.jfrdb import JFRDbTournamentInfo
- from jfr_playoff.tournamentinfo.jfrhtml import JFRHtmlTournamentInfo
- from jfr_playoff.tournamentinfo.tcjson import TCJsonTournamentInfo
+ from jfr_playoff.data.tournament.jfrdb import JFRDbTournamentInfo
+ from jfr_playoff.data.tournament.jfrhtml import JFRHtmlTournamentInfo
+ from jfr_playoff.data.tournament.tcjson import TCJsonTournamentInfo
if (database is not None) and ('database' in settings):
clients.append(JFRDbTournamentInfo(settings, database))
if 'link' in settings:
diff --git a/jfr_playoff/tournamentinfo/jfrdb.py b/jfr_playoff/data/tournament/jfrdb.py
index 0f39b47..48645df 100644
--- a/jfr_playoff/tournamentinfo/jfrdb.py
+++ b/jfr_playoff/data/tournament/jfrdb.py
@@ -1,7 +1,7 @@
import jfr_playoff.sql as p_sql
from jfr_playoff.logger import PlayoffLogger
-from jfr_playoff.tournamentinfo import TournamentInfoClient
+from jfr_playoff.data.tournament import TournamentInfoClient
SWISS_TIE_WARNING = 'tie detected in swiss %s.' + \
' Make sure to resolve the tie by arranging teams' + \
diff --git a/jfr_playoff/tournamentinfo/jfrhtml.py b/jfr_playoff/data/tournament/jfrhtml.py
index 8f40c55..017ce3b 100644
--- a/jfr_playoff/tournamentinfo/jfrhtml.py
+++ b/jfr_playoff/data/tournament/jfrhtml.py
@@ -3,7 +3,7 @@ import re
from jfr_playoff.logger import PlayoffLogger
from jfr_playoff.remote import RemoteUrl as p_remote
-from jfr_playoff.tournamentinfo import TournamentInfoClient
+from jfr_playoff.data.tournament import TournamentInfoClient
class JFRHtmlTournamentInfo(TournamentInfoClient):
diff --git a/jfr_playoff/tournamentinfo/tcjson.py b/jfr_playoff/data/tournament/tcjson.py
index 5a81ef3..5e375ed 100644
--- a/jfr_playoff/tournamentinfo/tcjson.py
+++ b/jfr_playoff/data/tournament/tcjson.py
@@ -3,7 +3,7 @@ import urlparse
from jfr_playoff.logger import PlayoffLogger
from jfr_playoff.remote import RemoteUrl as p_remote
-from jfr_playoff.tournamentinfo import TournamentInfoClient
+from jfr_playoff.data.tournament import TournamentInfoClient
FLAG_CDN_URL = 'https://cdn.tournamentcalculator.com/flags/'
diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py
index 9d48b57..1c0bcd8 100644
--- a/jfr_playoff/matchinfo.py
+++ b/jfr_playoff/matchinfo.py
@@ -4,10 +4,11 @@ from urlparse import urljoin
import jfr_playoff.sql as p_sql
from jfr_playoff.dto import Match, Team
from jfr_playoff.remote import RemoteUrl as p_remote
-from jfr_playoff.data import ResultInfo
-from jfr_playoff.tournamentinfo import TournamentInfo
+from jfr_playoff.data.info import ResultInfo
+from jfr_playoff.data.tournament import TournamentInfo
from jfr_playoff.logger import PlayoffLogger
+
class MatchInfo(ResultInfo):
matches = {}