From 0b5814725078a4d1a69999487108c0837451e3f2 Mon Sep 17 00:00:00 2001 From: Styrr Date: Sun, 17 Jul 2022 15:52:19 +0200 Subject: [PATCH] introduce configuration possibility exclude dumps older than a threshold date map specific in the map_directory_mapping.yaml --- 02_loot_generator_parallel.py | 14 ++++++++++--- config/map_directory_mapping.yaml | 34 +++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/02_loot_generator_parallel.py b/02_loot_generator_parallel.py index 819a51b..91276cf 100644 --- a/02_loot_generator_parallel.py +++ b/02_loot_generator_parallel.py @@ -31,7 +31,7 @@ with open(f'config/{config["config"]["loose"]["forced_yaml"]}', 'r') as fin: FORCED_LOOSE = yaml.load(fin, Loader=yaml.FullLoader) with open(f'config/{config["server"]["map_directory_mapping_yaml"]}', 'r') as fin: - loose_loot_dir_map = yaml.load(fin, Loader=yaml.FullLoader) + directory_mapping = yaml.load(fin, Loader=yaml.FullLoader) tarkov_server_dir = Path(config["server"]["location"]) loot_dump_archive = Path(config["archives"]["target_folder"]) / config["archives"]["loot_filename"] @@ -51,11 +51,19 @@ def parse_dumps(input): text = bio.read() fi = json.loads(text) + threshold_date = datetime.datetime.strptime( + directory_mapping[fi["data"]["Name"]]["threshold_date"], + "%Y-%m-%d" + ) datestr = fname.split(".getLocalloot_")[-1].split(".")[0] date = datetime.datetime.strptime(datestr, "%Y-%m-%d_%H-%M-%S") - if fi["data"] is not None and fi["data"]["Name"] not in blacklist: + if ( + fi["data"] is not None + and fi["data"]["Name"] not in blacklist + and date > threshold_date + ): basic_info = { "map": fi["data"]["Name"], "filehash": hash_file(text), @@ -213,7 +221,7 @@ def main(): print(f"took {time.time() - time_start} seconds") for mi, cnt in map_counts.items(): - for mapdir in loose_loot_dir_map[mi]: + for mapdir in directory_mapping[mi]["name"]: with open(loose_loot_dir / mapdir / "looseLoot.json", "w") as fout: json.dump(loose_loot_distribution[mi], fout, indent=1) diff --git a/config/map_directory_mapping.yaml b/config/map_directory_mapping.yaml index bf967cd..f9fc67c 100644 --- a/config/map_directory_mapping.yaml +++ b/config/map_directory_mapping.yaml @@ -1,18 +1,34 @@ --- Customs: -- bigmap + name: + - bigmap + threshold_date: "2022-06-27" Factory: -- factory4_day -- factory4_night + name: + - factory4_day + - factory4_night + threshold_date: "2022-06-27" Interchange: -- interchange + name: + - interchange + threshold_date: "2022-06-27" Laboratory: -- laboratory + name: + - laboratory + threshold_date: "2020-01-01" Lighthouse: -- lighthouse + name: + - lighthouse + threshold_date: "2022-06-27" ReserveBase: -- rezervbase + name: + - rezervbase + threshold_date: "2022-06-27" Shoreline: -- shoreline + name: + - shoreline + threshold_date: "2022-06-27" Woods: -- woods \ No newline at end of file + name: + - woods + threshold_date: "2022-06-27" \ No newline at end of file