mirror of
git://git.yoctoproject.org/yocto-autobuilder-helper.git
synced 2025-07-19 20:59:02 +02:00
scripts/docs_add_banner: Fix several issues
* Fix a syntax error causing the script to fail * Skip symlinks files (symlink directories were already skipped) * Drop unneeded whitespace * Abstract path join to a variable Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
5dd90ea43b
commit
9d7820da27
|
@ -9,13 +9,8 @@
|
|||
#
|
||||
#
|
||||
|
||||
|
||||
import os
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
html_content_dunfell = '''
|
||||
<div id="outdated-warning">This document is outdated, you should select the <a href="https://docs.yoctoproject.org/dunfell">latest release version</a> in this series.</div>
|
||||
<div xml:lang="en" class="body" lang="en">
|
||||
|
@ -69,15 +64,18 @@ def add_banner_old_docs(dir):
|
|||
html_replacement = html_content
|
||||
|
||||
for filename in filenames:
|
||||
fullfile = os.path.join(root, filename)
|
||||
if os.path.islink(fullfile):
|
||||
continue
|
||||
if filename.endswith('.html'):
|
||||
with open(os.path.join(root, filename), 'r', encoding="ISO-8859-1") as f:
|
||||
with open(fullfile, 'r', encoding="ISO-8859-1") as f:
|
||||
current_content = f.read()
|
||||
with open(os.path.join(root, filename), 'w', encoding="ISO-8859-1") as f:
|
||||
f.write(current_content.replace('<body>', '<body>' + html_replacement)).replace('</body>', last_div + '</body>'))
|
||||
if filename.endswith('.css'):
|
||||
with open(os.path.join(root, filename), 'r', encoding="ISO-8859-1") as f:
|
||||
with open(fullfile, 'w', encoding="ISO-8859-1") as f:
|
||||
f.write(current_content.replace('<body>', '<body>' + html_replacement).replace('</body>', last_div + '</body>'))
|
||||
elif filename.endswith('.css'):
|
||||
with open(fullfile, 'r', encoding="ISO-8859-1") as f:
|
||||
css_content = f.read()
|
||||
with open(os.path.join(root, filename), 'w', encoding="ISO-8859-1") as f:
|
||||
with open(fullfile, 'w', encoding="ISO-8859-1") as f:
|
||||
f.write(css_content.replace(css_content[css_content.find('body {'):css_content.find('}'[0])], 'body {' + css_replacement_content ))
|
||||
|
||||
add_banner_old_docs('.')
|
||||
|
|
Loading…
Reference in New Issue
Block a user