Merge pull request #24 from Jylpah/staging

Config file: Histogram bucket support
This commit is contained in:
Jylpah authored and GitHub committed 2020-07-10 20:10:09 +03:00
commit a5617f4120
2 files changed
+33 -4

No files matched your search

+21
View File
@@ -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()
+12 -4
View File
@@ -1,3 +1,6 @@
## Configuration file for blitz-tools
## Rename it 'blitzstats.ini' and place it to the same directory with the scripts
[OPTIONS]
## You may set your preferred commandline param defaults here
#opt_analyzer_extended = False
@@ -5,17 +8,22 @@
#opt_analyzer_stat_func = player
[WG]
## Find your WG account_id : https://developers.wargaming.net/reference/all/wotb/account/list/
# wg_id = 0
## wg_account format: nick@server, where server is either 'eu', 'ru', 'na', 'asia' or 'china'.
## China is not supported since WG API stats are not available there
# wg_account = your_nick@eu
## Find your WG account_id : https://developers.wargaming.net/reference/all/wotb/account/list/
## set either wg_account OR wg_id
# wg_id = 0
## WG API limits requests / sec to 10 for mobile apps.
## You can register your "own" server app and
## upgrade the rate limit to 20 requests / sec.
## Check https://developers.wargaming.net/documentation/guide/getting-started/
# wg_app_id = XXXXXXXXXXX
[ANALYZER]
## Define histogram buckets. Valid JSON required. The last field is the maximum, therefore very large.
# histogram_buckets = { "wins" : [ 0, 0.40, 0.5, 0.60, 0.70, 1],
# "damage_dealt" : [ 0, 500, 1000, 1500, 2000, 1000000],
# "battles" : [ 0, 1000, 5000, 10000, 15e3, 1e6 ] }