diff --git a/get_chances.py b/get_chances.py new file mode 100644 index 0000000..a486a58 --- /dev/null +++ b/get_chances.py @@ -0,0 +1,20 @@ +import ast, csv, sys + +with open("plugins/badge_plugin.py") as f: + tree = ast.parse(f.read()) + +ret = [["Badge name","Chance to pull"]] + +for statement in tree.body: + if type(statement)==ast.Assign and statement.targets[0].id=="badge_weights": + # Bingo! + d = statement.value + assert len(d.keys)==len(d.values) + for i in range(len(d.keys)): + key = d.keys[i].s + value = d.values[i].n + ret.append([key,f"{value:0.2%}"]) + +ret[1:]=sorted(ret[1:],key=lambda x: -float(x[1][:-1])) +w = csv.writer(sys.stdout) +w.writerows(ret)