diff --git a/domjudge_utility/dump.py b/domjudge_utility/dump.py index 0562cf3..0f05d25 100644 --- a/domjudge_utility/dump.py +++ b/domjudge_utility/dump.py @@ -62,6 +62,8 @@ def __init__(self, config: DumpConfig = None): self.groups_dict = None self.teams_dict = None + self.logger = None + def output_to_file(self, filepath: str, data: str, if_not_exists=False): dir_name = os.path.join(self.config.saved_dir, filepath) @@ -72,6 +74,9 @@ def output_to_file(self, filepath: str, data: str, if_not_exists=False): f.write(data) def init_logging(self): + if self.logger is not None: + return + self.logger = logging.getLogger(__name__) self.logger.setLevel(logging.INFO) @@ -113,7 +118,7 @@ def request_json(self, endpoint, params={}): return content else: - file_path = os.path.join(self.config.base_file_path, endpoint) + file_path = os.path.join(self.config.base_file_path, "domjudge", "api", endpoint) self.logger.info('GET {}'.format(file_path)) with open(file_path, 'r') as f: return f.read() @@ -636,3 +641,10 @@ def dump(self): self.dump_source_code() self.dump_images() self.dump_3rd_data() + + def load_domjudge_api(self): + self.config.exported_data.domjudge_api = False + + self.init_logging() + self.dump_domjudge_api() + self.process_domjudge_raw_data() diff --git a/domjudge_utility/dump_config.py b/domjudge_utility/dump_config.py index 86c6512..95ddf36 100644 --- a/domjudge_utility/dump_config.py +++ b/domjudge_utility/dump_config.py @@ -34,7 +34,7 @@ def __init__(self, exported_data_dict): self.scoreboard_excel_data = DumpConfig.get_config_with_default_value( exported_data_dict, 'scoreboard_excel_data', False) - def __init__(self, config_dict): + def __init__(self, config_dict={}): self.base_file_path = self.get_config_with_default_value( config_dict, 'base_file_path', '')