right-tree/process_svg.py
Dana Lambert 75e834d8ab Add helper svg processing script
- Removes colons from inkcape svg export property names
2021-12-09 07:48:19 +13:00

24 lines
655 B
Python

import os
find_and_replace_mappings = {
"inkscape:": "inkscape",
"rdf:": "rdf",
"dc:": "dc",
"cc:": "cc",
"xmlns:": "xmlns",
"sodipodi:": "sodipodi"
}
SVG_PATH = "./assets/img/habitatSVG/"
for filename in os.listdir(SVG_PATH):
if filename.endswith(".svg"):
print(f"Processing {filename}")
with open (f"{SVG_PATH}{filename}", "r") as myfile:
data=myfile.read()
for find_val, replace_val in find_and_replace_mappings.items():
data = data.replace(find_val, replace_val)
with open (f"{SVG_PATH}{filename}", "w") as myfile:
myfile.write(data)