Changeset - 2156c5a17dfe
[Not reviewed]
default
0 1 0
Laman - 3 years ago 2021-10-13 14:56:00

printing the rank change
1 file changed with 11 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rank_progress.py
Show inline comments
 
@@ -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()
 

	
0 comments (0 inline, 0 general)