From 25fdf6578850ff18b37ac94f87a6b455e8364d0f Mon Sep 17 00:00:00 2001 From: Midgard Date: Tue, 17 Dec 2024 22:55:09 +0100 Subject: [PATCH] Allow purging groups of messages --- purge.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/purge.py b/purge.py index b04bf94..b3a666d 100755 --- a/purge.py +++ b/purge.py @@ -30,15 +30,15 @@ def walk_and_discard(obj, prefix): result = {} for k, v in obj.items(): fqkey = f"{prefix}{k}" - if isinstance(v, str): - if fqkey not in to_discard: + if fqkey not in to_discard: + if isinstance(v, str): result[k] = v - elif hasattr(v, "items"): - result[k] = walk_and_discard(v, f"{prefix}{k}.") + elif hasattr(v, "items"): + result[k] = walk_and_discard(v, f"{prefix}{k}.") return result -path_langs = os.path.join(path_mc_repo, "langs") +path_langs = os.path.join(path_mc_repo, "langs/layers") json_files = [ f for f in os.listdir(path_langs) if os.path.isfile(os.path.join(path_langs, f)) and f.endswith(".json")