From 80292c05a38bbce6a3472ce2c8c86bd3f43e7512 Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 20 Feb 2019 10:06:07 +0100 Subject: Ordering ranking editions in editions menu --- scripts/rankings-editions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'scripts/rankings-editions.py') diff --git a/scripts/rankings-editions.py b/scripts/rankings-editions.py index 42d036f..de1f2d6 100644 --- a/scripts/rankings-editions.py +++ b/scripts/rankings-editions.py @@ -1,11 +1,12 @@ import copy, json, sys +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') -editions = {} +editions = OrderedDict() for date_config in dates_config: year = date_config['name'].split(' ')[1] if year not in editions: @@ -30,7 +31,7 @@ for year, dates in editions.iteritems(): link['href'] = date[1] link['datetime'] = date[2] group.append(link) - date_group.append(group) + 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')) -- cgit v1.2.3