Add helper svg processing script
- Removes colons from inkcape svg export property names
This commit is contained in:
parent
2c2a362b9a
commit
75e834d8ab
2 changed files with 28 additions and 0 deletions
4
dev
4
dev
|
@ -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
24
process_svg.py
Normal 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)
|
Loading…
Reference in a new issue