From 13e5db0637204b9164ed5cab4cef129505548407 Mon Sep 17 00:00:00 2001 From: emkael Date: Tue, 7 Feb 2023 17:30:13 +0100 Subject: Python 2.x -> 3.x conversion --- scripts/rankings-editions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'scripts/rankings-editions.py') diff --git a/scripts/rankings-editions.py b/scripts/rankings-editions.py index de1f2d6..bdbe46f 100644 --- a/scripts/rankings-editions.py +++ b/scripts/rankings-editions.py @@ -3,8 +3,8 @@ from collections import OrderedDict from bs4 import BeautifulSoup as bs4 -dates_config = json.load(file('config/dates.json')) -output_file = bs4(file(sys.argv[1]), 'lxml') +dates_config = json.load(open('config/dates.json')) +output_file = bs4(open(sys.argv[1]), 'lxml') editions = OrderedDict() for date_config in dates_config: @@ -17,12 +17,12 @@ for date_config in dates_config: date_config['date'] )) -template = bs4(file('templates/ranking.html'), 'lxml') +template = bs4(open('templates/ranking.html'), 'lxml') date_group = template.select('#editions')[0].extract() year_group = date_group.select('div[role="group"]')[0].extract() ranking_link = year_group.select('.btn-default')[0].extract() -for year, dates in editions.iteritems(): +for year, dates in editions.items(): group = copy.copy(year_group) group.select('.year')[0].string = str(year) for date in dates[::-1]: @@ -34,4 +34,4 @@ for year, dates in editions.iteritems(): date_group.insert(0, group) output_file.select('#editions')[0].replace_with(date_group) -file(sys.argv[1], 'w').write(output_file.prettify().encode('utf-8')) +open(sys.argv[1], 'w').write(output_file.prettify()) -- cgit v1.2.3