Add helper svg processing script

- Removes colons from inkcape svg export property names
This commit is contained in:
Dana Lambert 2021-12-06 10:27:35 +13:00
parent 2c2a362b9a
commit 75e834d8ab
2 changed files with 28 additions and 0 deletions

4
dev
View file

@ -133,6 +133,10 @@ cmd_renew_certifcate() {
cmd_start_production cmd_start_production
} }
cmd_process_svg_files() {
docker run -v $PWD/frontend/src/assets/:/app/assets -v $PWD/process_svg.py:/app/process_svg.py -w /app python:3.8-slim-bullseye python process_svg.py
}
# Run the command # Run the command
cmd="$1" cmd="$1"
"cmd_$cmd" "$@" "cmd_$cmd" "$@"

24
process_svg.py Normal file
View file

@ -0,0 +1,24 @@
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)