2021-12-14 14:02:19 +08:00
|
|
|
import json
|
|
|
|
import os
|
|
|
|
|
|
|
|
with open("generated/manifest.json") as manifest:
|
|
|
|
style_map = json.load(manifest)
|
|
|
|
|
|
|
|
for folder in ("generated", "dist"):
|
|
|
|
for root, _, files in os.walk(folder):
|
|
|
|
for file in files:
|
|
|
|
if file.endswith(".html"):
|
2022-01-21 21:44:12 +08:00
|
|
|
with open(os.path.join(root, file), encoding="utf-8") as old_file:
|
2021-12-14 14:02:19 +08:00
|
|
|
content = old_file.read()
|
|
|
|
for old_name, new_name in style_map.items():
|
|
|
|
content = content.replace(old_name, new_name)
|
2022-01-21 21:44:12 +08:00
|
|
|
with open(os.path.join(root, file), "w", encoding="utf-8") as new_file:
|
2021-12-14 14:02:19 +08:00
|
|
|
new_file.write(content)
|
2022-01-21 21:44:12 +08:00
|
|
|
elif (
|
|
|
|
file.startswith("style.")
|
|
|
|
and file.endswith(".css")
|
|
|
|
and file not in list(style_map.values())
|
|
|
|
):
|
2021-12-14 14:02:19 +08:00
|
|
|
os.remove(os.path.join(root, file))
|