From 8f795b1d445441daab5ffb75060a6dbf8ed0934a Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 8 Sep 2017 01:28:21 +0200 Subject: Renaming scripts so that their names make sense --- scripts/rankings-tables-compile.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 scripts/rankings-tables-compile.py (limited to 'scripts/rankings-tables-compile.py') diff --git a/scripts/rankings-tables-compile.py b/scripts/rankings-tables-compile.py new file mode 100644 index 0000000..52b036f --- /dev/null +++ b/scripts/rankings-tables-compile.py @@ -0,0 +1,26 @@ +import os, sys +from bs4 import BeautifulSoup as bs4 + +ranking_date = sys.argv[4] +subtitle = 'notowanie %s (%s), stan na %s' % ( + sys.argv[1], sys.argv[2], '.'.join(ranking_date.split('-')[::-1]) +) + +table = bs4(file('templates/ranking.html'), 'lxml') +table.select('.page-header h2 small')[0].string = subtitle + +table.select('table.data-table')[0]['data-ranking'] = '_data/%s.json' % ( + ranking_date) + +script_src = table.select('script[src="_res/ranking.js"]')[0] +script_src['src'] = '%s?%d' % ('_res/ranking.js', os.path.getmtime('http/_res/ranking.js')) + +rawlink = table.select('a#rawlink')[0] +rawlink['href'] = '%s/%s.csv' % (rawlink['href'], ranking_date) + +menu_file = file(sys.argv[3]) +menu = table.select('div.static-menu')[0] +menu.clear() +menu.append(bs4(menu_file, 'html.parser')) + +print table.prettify().encode('utf-8') -- cgit v1.2.3