diff --git a/dev b/dev index dc76aaa..2207222 100755 --- a/dev +++ b/dev @@ -133,6 +133,10 @@ cmd_renew_certifcate() { 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 cmd="$1" "cmd_$cmd" "$@" diff --git a/process_svg.py b/process_svg.py new file mode 100644 index 0000000..8a33377 --- /dev/null +++ b/process_svg.py @@ -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)