From 21169d812779579f6a5c3b610013822bac8a9d47 Mon Sep 17 00:00:00 2001 From: emkael Date: Sat, 9 Nov 2019 16:14:49 +0100 Subject: Refactoring player generation scripts. Fixes #16 --- scripts/players-compile.py | 15 +++------------ scripts/players-prepare-template.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 scripts/players-prepare-template.py (limited to 'scripts') diff --git a/scripts/players-compile.py b/scripts/players-compile.py index 66750d1..4007cfa 100644 --- a/scripts/players-compile.py +++ b/scripts/players-compile.py @@ -1,22 +1,13 @@ -import copy, os, sys +import os, sys import simplejson as json -from bs4 import BeautifulSoup as bs4 from math import ceil from pyranking.fetch import fetch_ranking -output_directory = sys.argv[1] +output_directory = sys.argv[2] pagesize = 100.0 -template = bs4(file('templates/player.html'), 'lxml') -menu_file = sys.argv[2] -menu_content = bs4(file(menu_file), 'html.parser') -menu = template.select('div.static-menu')[0] -menu.append(copy.copy(menu_content)) - -file(os.path.join(output_directory, 'index.html'), 'w').write(template.prettify().encode('utf-8')) - dates = {} -for date_config in json.load(file('config/dates.json')): +for date_config in json.load(file(sys.argv[1])): dates[date_config['date']] = date_config['url'] players = {} diff --git a/scripts/players-prepare-template.py b/scripts/players-prepare-template.py new file mode 100644 index 0000000..3d81482 --- /dev/null +++ b/scripts/players-prepare-template.py @@ -0,0 +1,13 @@ +import copy, os, sys +import simplejson as json +from bs4 import BeautifulSoup as bs4 + +output_directory = sys.argv[1] + +template = bs4(file('templates/player.html'), 'lxml') +menu_file = sys.argv[2] +menu_content = bs4(file(menu_file), 'html.parser') +menu = template.select('div.static-menu')[0] +menu.append(copy.copy(menu_content)) + +file(os.path.join(output_directory, 'index.html'), 'w').write(template.prettify().encode('utf-8')) -- cgit v1.2.3