# HG changeset patch # User Laman # Date 2021-10-13 14:56:00 # Node ID 2156c5a17dfe8bed03df18374edada3d3fa9bce6 # Parent 3d0ab62fd174c9d55ebd35cd60ae4683ff8a6eea printing the rank change diff --git a/rank_progress.py b/rank_progress.py --- a/rank_progress.py +++ b/rank_progress.py @@ -13,6 +13,8 @@ args = parser.parse_args() class Record: def __init__(self, tokens, source): + self.source = source + self.pin = int(tokens[0]) self.country_code = tokens[2] self.rating_before = int(tokens[8]) @@ -23,7 +25,7 @@ class Record: tournament_code = tokens[5] self.date = datetime.strptime(tournament_code[1:7], "%y%m%d") - self.source = source + self.rank_change = (rating_to_rank(self.rating_before), rating_to_rank(self.rating_after)) @classmethod def parse(cls, line): @@ -35,7 +37,8 @@ class Record: return cls(tokens, line) def __str__(self): - return self.source + s = self.source + " {} -> {}".format(*self.rank_change) + return s def parse_record(record): @@ -48,6 +51,12 @@ def round_rating(r): return (r+50)//100*100 +def rating_to_rank(rating): + rank_list = [str(i)+"k" for i in range(30, 0, -1)] + [str(i)+"d" for i in range(1, 8)] + key = round_rating(rating)//100 + return rank_list[min(key+9, 36)] + + since = datetime.strptime(args.since, "%Y%m%d") to = datetime.strptime(args.to, "%Y%m%d") if args.to else datetime.now()