mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
29 lines
722 B
Python
29 lines
722 B
Python
# import required module
|
|
from pathlib import Path
|
|
import os
|
|
import codecs
|
|
|
|
# assign directory
|
|
directory = '.'
|
|
|
|
print( "Replacing head tag in all html files" )
|
|
|
|
# Read template file
|
|
with open( os.path.dirname(__file__) + '/docs-header.html', 'r') as file:
|
|
newhead = file.read()
|
|
|
|
# iterate over files in
|
|
# that directory
|
|
files = Path(directory).glob('*.html')
|
|
for file in files:
|
|
#print(file)
|
|
#with open(file, 'r') as fileread:
|
|
with codecs.open(file, 'r', encoding='utf-8', errors='ignore') as fileread:
|
|
filedata = fileread.read()
|
|
# Replace the target string
|
|
filedata = filedata.replace( '<head>', newhead )
|
|
|
|
# Write the file out again
|
|
with open(file, 'w') as filewrite:
|
|
filewrite.write(filedata)
|