2021-10-21 20:05:07 +00:00
|
|
|
import data as d
|
2021-10-21 20:42:47 +00:00
|
|
|
|
|
|
|
class AutoVivification(dict):
|
|
|
|
def __getitem__(self, item):
|
|
|
|
try:
|
|
|
|
return dict.__getitem__(self, item)
|
|
|
|
except KeyError:
|
|
|
|
value = self[item] = type(self)()
|
|
|
|
return value
|
|
|
|
|
2021-10-21 20:05:07 +00:00
|
|
|
class Module:
|
|
|
|
config = None
|
|
|
|
data = None
|
|
|
|
results = None
|
|
|
|
def __init__(self, config, apikey, tbakey, timestamp):
|
|
|
|
pass
|
|
|
|
def validate_config(self):
|
|
|
|
pass
|
|
|
|
def load_data(self):
|
|
|
|
pass
|
|
|
|
def process_data(self, exec_threads):
|
|
|
|
pass
|
|
|
|
def push_results(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class Match:
|
|
|
|
config = None
|
|
|
|
apikey = None
|
|
|
|
tbakey = None
|
|
|
|
timestamp = None
|
|
|
|
teams = None
|
|
|
|
|
2021-10-21 20:42:47 +00:00
|
|
|
data = []
|
2021-10-21 20:05:07 +00:00
|
|
|
|
|
|
|
def __init__(self, config, apikey, tbakey, timestamp, teams):
|
|
|
|
self.config = config
|
|
|
|
self.apikey = apikey
|
|
|
|
self.tbakey = tbakey
|
|
|
|
self.timestamp = timestamp
|
|
|
|
self.teams = teams
|
|
|
|
|
|
|
|
def validate_config(self):
|
2021-10-21 20:42:47 +00:00
|
|
|
return True, ""
|
|
|
|
"""
|
2021-10-21 20:28:29 +00:00
|
|
|
if self.config == None:
|
2021-10-21 20:42:47 +00:00
|
|
|
return False, "config cannot be empty"
|
2021-10-21 20:28:29 +00:00
|
|
|
elif self.apikey == None or self.apikey == "":
|
2021-10-21 20:42:47 +00:00
|
|
|
return False, "apikey cannot be empty"
|
2021-10-21 20:28:29 +00:00
|
|
|
elif self.tbakey == None or self.tbakey == "":
|
2021-10-21 20:42:47 +00:00
|
|
|
return False, "tbakey cannot be empty"
|
2021-10-21 20:28:29 +00:00
|
|
|
elif not(self.config["scope"] in ["competition", "season", "none"]):
|
2021-10-21 20:42:47 +00:00
|
|
|
return False, "scope must be one of: (competition, season, none)"
|
2021-10-21 20:28:29 +00:00
|
|
|
elif not(self.config["agglomeration"] in ["none", "mean"]):
|
2021-10-21 20:42:47 +00:00
|
|
|
return False, "agglomeration must be one of: (none, mean)"
|
2021-10-21 20:28:29 +00:00
|
|
|
else:
|
2021-10-21 20:42:47 +00:00
|
|
|
return True, ""
|
|
|
|
"""
|
2021-10-21 20:05:07 +00:00
|
|
|
|
|
|
|
def load_data(self):
|
2021-10-21 20:42:47 +00:00
|
|
|
scope = self.config["scope"]
|
|
|
|
for team in self.teams:
|
|
|
|
competitions = d.get_team_conpetitions(self.apikey, team, scope) # unimplemented
|
|
|
|
for competition in competitions:
|
|
|
|
for variable in self.config["tests"]:
|
2021-10-21 20:56:06 +00:00
|
|
|
match_data = d.get_team_match_data(self.apikey, competition, team, variable) # needs modified implementation
|
2021-10-21 20:42:47 +00:00
|
|
|
self.data.append((team, competition, variable, match_data))
|
2021-10-21 20:05:07 +00:00
|
|
|
|
|
|
|
def process_data(self, exec_threads):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def push_results(self):
|
|
|
|
pass
|