From d35b77014feb9b559281bb981bd53f7bd0cb6b50 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Sun, 21 Oct 2018 16:40:47 -0500 Subject: [PATCH] Added support for filtering at the individual stat level --- external/stats.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/external/stats.py b/external/stats.py index 94b8764..dad52c6 100644 --- a/external/stats.py +++ b/external/stats.py @@ -1,4 +1,4 @@ -import os, json +import os, json, copy from minecraft_manager.models import Player from django.conf import settings @@ -16,9 +16,13 @@ def get_stats(): with open(stats_dir + "/" + filename) as json_file: raw = json.load(json_file)['stats'] clean = {} - for r in raw: - if not any(sf.lower() in r.lower() for sf in stats_filter): - clean[r] = raw[r] + raw_copy = copy.deepcopy(raw) + for ra in raw_copy: + if not any(sf.lower() in ra.lower() for sf in stats_filter): + for r in raw_copy[ra]: + if any(sf.lower() in r.lower() for sf in stats_filter): + del raw[ra][r] + clean[ra] = raw[ra] uuid = filename.replace(".json", "") stats[uuid] = clean return stats