villeurbanne-2018: make template preparation script python3 compliant (#51912)
This commit is contained in:
parent
3e577835bf
commit
e3361ae536
|
@ -1,10 +1,15 @@
|
|||
#! /usr/bin/env python
|
||||
|
||||
import six
|
||||
import subprocess
|
||||
import sys
|
||||
from lxml import etree
|
||||
from lxml.html import HTMLParser
|
||||
from urlparse import urljoin
|
||||
|
||||
if six.PY2:
|
||||
from urlparse import urljoin
|
||||
else:
|
||||
from urllib.parse import urljoin
|
||||
|
||||
html_parser = HTMLParser(encoding='utf-8')
|
||||
|
||||
|
@ -42,7 +47,7 @@ for link in root.xpath('//link'):
|
|||
parent.remove(link)
|
||||
|
||||
external_js = '<script type="text/javascript" src="%s"></script>' % JS_URL
|
||||
head_content = etree.tostring(root, method='html')
|
||||
head_content = str(etree.tostring(root, method='html'))
|
||||
|
||||
# remove closing <html> because it will be closed later
|
||||
head_content = head_content.replace('</html>', '')
|
||||
|
@ -65,11 +70,10 @@ for link in root.xpath('//li[@class="compte"]'):
|
|||
link.remove(child)
|
||||
link.text = "{% block user-info %}{% endblock %}"
|
||||
|
||||
header_content = etree.tostring(root, method='html')
|
||||
|
||||
header_content = str(etree.tostring(root, method='html'))
|
||||
|
||||
subprocess.call(['wget', '--quiet', '-O', BANNER_FILENAME, '--convert-links', BANNER_URL])
|
||||
banner_content = open(BANNER_FILENAME).read().strip()
|
||||
banner_content = str(open(BANNER_FILENAME).read().strip())
|
||||
banner_content = banner_content.replace(BANNER_FILENAME, '')
|
||||
|
||||
publik_content = '''<div class="publik-container">
|
||||
|
@ -81,7 +85,7 @@ publik_content = '''<div class="publik-container">
|
|||
</div>'''
|
||||
|
||||
subprocess.call(['wget', '--quiet', '-O', FOOTER_FILENAME, '--convert-links', FOOTER_URL])
|
||||
footer_content = open(FOOTER_FILENAME).read().strip()
|
||||
footer_content = str(open(FOOTER_FILENAME).read().strip())
|
||||
footer_content = footer_content.replace(FOOTER_FILENAME, '')
|
||||
publik_footer = '''<div id="footer-wrapper">
|
||||
<div id="footer">
|
||||
|
|
Loading…
Reference in New Issue