From b57ca33c31a8af43f561a8625d8aae59d042bca3 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Thu, 27 Oct 2022 09:18:25 +0200 Subject: [PATCH] Logging: more digits for IDs and counts (#1141) * Logging: we now need 9 digits for IDs * Logging: we now need {dynamic} digits for IDs * Logging: we now need {dynamic} digits for counts --- Main.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/Main.py b/Main.py index 63f5b8a8..38100bd0 100644 --- a/Main.py +++ b/Main.py @@ -80,15 +80,30 @@ def main(args, seed=None, baked_server_options: Optional[Dict[str, object]] = No logger.info("Found World Types:") longest_name = max(len(text) for text in AutoWorld.AutoWorldRegister.world_types) - numlength = 8 + + max_item = 0 + max_location = 0 + for cls in AutoWorld.AutoWorldRegister.world_types.values(): + if cls.item_id_to_name: + max_item = max(max_item, max(cls.item_id_to_name)) + max_location = max(max_location, max(cls.location_id_to_name)) + + item_digits = len(str(max_item)) + location_digits = len(str(max_location)) + item_count = len(str(max(len(cls.item_names) for cls in AutoWorld.AutoWorldRegister.world_types.values()))) + location_count = len(str(max(len(cls.location_names) for cls in AutoWorld.AutoWorldRegister.world_types.values()))) + del max_item, max_location + for name, cls in AutoWorld.AutoWorldRegister.world_types.items(): if not cls.hidden and len(cls.item_names) > 0: - logger.info(f" {name:{longest_name}}: {len(cls.item_names):3} " - f"Items (IDs: {min(cls.item_id_to_name):{numlength}} - " - f"{max(cls.item_id_to_name):{numlength}}) | " - f"{len(cls.location_names):3} " - f"Locations (IDs: {min(cls.location_id_to_name):{numlength}} - " - f"{max(cls.location_id_to_name):{numlength}})") + logger.info(f" {name:{longest_name}}: {len(cls.item_names):{item_count}} " + f"Items (IDs: {min(cls.item_id_to_name):{item_digits}} - " + f"{max(cls.item_id_to_name):{item_digits}}) | " + f"{len(cls.location_names):{location_count}} " + f"Locations (IDs: {min(cls.location_id_to_name):{location_digits}} - " + f"{max(cls.location_id_to_name):{location_digits}})") + + del item_digits, location_digits, item_count, location_count AutoWorld.call_stage(world, "assert_generate")