From c36f49555adc4ecf20a36f4b3580233e062b926d Mon Sep 17 00:00:00 2001 From: Jylpah Date: Fri, 10 Jul 2020 20:01:13 +0300 Subject: [PATCH] Config file support for histogram buckets --- analyze_wotb_replays.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/analyze_wotb_replays.py b/analyze_wotb_replays.py index c0bcabf..8ddd7e1 100644 --- a/analyze_wotb_replays.py +++ b/analyze_wotb_replays.py @@ -550,6 +550,16 @@ async def main(argv): except (KeyError, configparser.NoSectionError) as err: bu.error(exception=err) + try: + if 'ANALYZER' in config.sections(): + configAnalyzer = config['ANALYZER'] + histogram_fields_str = configAnalyzer.get('histogram_buckets', None) + if histogram_fields_str != None: + set_histogram_buckets(json.loads(histogram_fields_str)) + + except (KeyError, configparser.NoSectionError) as err: + bu.error(exception=err) + try: if 'WG' in config.sections(): configWG = config['WG'] @@ -690,6 +700,17 @@ async def main(argv): if wi != None: await wi.close() return None + +def set_histogram_buckets(json: dict): + global histogram_fields + try: + for field in json.keys(): + histogram_fields[field][1] = json[field] + except (KeyError, Exception) as err: + bu.error(exception=err) + return histogram_fields + + def process_player_dist(results: list, player_stats: dict, stat_id_map: dict): """Process player distribution""" hist_stats = dict()