summaryrefslogtreecommitdiff
path: root/scripts/rankings-tables-compile.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-09-08 01:28:21 +0200
committeremkael <emkael@tlen.pl>2017-09-08 01:28:21 +0200
commit8f795b1d445441daab5ffb75060a6dbf8ed0934a (patch)
tree15e55a2a7e03867ac0cccfb8303674d478510503 /scripts/rankings-tables-compile.py
parent655a9847513332e8e119f37f7ed95f4ab002b1a1 (diff)
Renaming scripts so that their names make sense
Diffstat (limited to 'scripts/rankings-tables-compile.py')
-rw-r--r--scripts/rankings-tables-compile.py26
1 files changed, 26 insertions, 0 deletions
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')