diff options
author | emkael <emkael@tlen.pl> | 2017-09-07 02:10:36 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-09-07 02:10:36 +0200 |
commit | 4060fa99c23bca17895029ae1ffad24d0d024269 (patch) | |
tree | cf4f322e236d913e238366a2de30727d0d2561cb /scripts/static.py | |
parent | 26f2934bcdfec9b32131ec01bbdd493146b3ad57 (diff) |
Moving *.py scripts to separate directory, cleaning things up
Diffstat (limited to 'scripts/static.py')
-rw-r--r-- | scripts/static.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/static.py b/scripts/static.py new file mode 100644 index 0000000..16d82ae --- /dev/null +++ b/scripts/static.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') |