From d2ced284ea3a2d1e085471cb777e50bfa68cfe6f Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Thu, 21 Oct 2021 20:42:47 +0000 Subject: [PATCH] added working load_data for Match module Signed-off-by: Arthur Lu Former-commit-id: 8e8c19c5fd279a6a32e8379652edc5f00d36c3d7 --- src/cli/module.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/cli/module.py b/src/cli/module.py index e1ed08d..518ebf7 100644 --- a/src/cli/module.py +++ b/src/cli/module.py @@ -1,4 +1,13 @@ import data as d + +class AutoVivification(dict): + def __getitem__(self, item): + try: + return dict.__getitem__(self, item) + except KeyError: + value = self[item] = type(self)() + return value + class Module: config = None data = None @@ -21,8 +30,7 @@ class Match: timestamp = None teams = None - data = None - results = None + data = [] def __init__(self, config, apikey, tbakey, timestamp, teams): self.config = config @@ -32,21 +40,30 @@ class Match: self.teams = teams def validate_config(self): + return True, "" + """ if self.config == None: - return "config cannot be empty" + return False, "config cannot be empty" elif self.apikey == None or self.apikey == "": - return "apikey cannot be empty" + return False, "apikey cannot be empty" elif self.tbakey == None or self.tbakey == "": - return "tbakey cannot be empty" + return False, "tbakey cannot be empty" elif not(self.config["scope"] in ["competition", "season", "none"]): - return "scope must be one of: (competition, season, none)" + return False, "scope must be one of: (competition, season, none)" elif not(self.config["agglomeration"] in ["none", "mean"]): - return "agglomeration must be one of: (none, mean)" + return False, "agglomeration must be one of: (none, mean)" else: - return None + return True, "" + """ def load_data(self): - pass + 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"]: + match_data = d.get_team_match_data(self.apikey, competition, team) # needs modified implementation + self.data.append((team, competition, variable, match_data)) def process_data(self, exec_threads): pass