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/statics-compile.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 scripts/statics-compile.py (limited to 'scripts/statics-compile.py') diff --git a/scripts/statics-compile.py b/scripts/statics-compile.py new file mode 100644 index 0000000..16d82ae --- /dev/null +++ b/scripts/statics-compile.py @@ -0,0 +1,34 @@ +import copy, os, sys +from bs4 import BeautifulSoup as bs4 + +content_files = [] +page_header = '' + +arguments = sys.argv[1:] + +while True: + page_header = arguments[0] + arguments = arguments[1:] + if os.path.exists(page_header): + content_files.append(page_header) + page_header = '' + if len(arguments) == 0: + break + +template = bs4(file('templates/static.html'), 'lxml') + +content_wrapper = template.find('div', {'id': 'wrapper'}).extract() +del content_wrapper['id'] + +template.select('h2 small')[0].string = page_header + +footer = template.find('div', {'id': 'footer'}) + +for content_file in content_files: + content = copy.copy(content_wrapper) + content.div.append( + bs4(file(content_file).read(), 'html.parser') + ) + footer.insert_before(content) + +print template.prettify().encode('utf-8') -- cgit v1.2.3