1
Fork 0
mirror of https://github.com/Steffo99/emblematic.git synced 2024-11-27 17:04:19 +00:00

#32: Preserve paths when generating

This commit is contained in:
Steffo 2024-07-01 18:14:36 +02:00
parent a7f4e38aea
commit f79c3d3d46
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

View file

@ -85,22 +85,25 @@ def basic(bg_file, icon_paths, icon_fill, output_dir, width, height, icon_shadow
if 0 < sum(map(bool, [icon_shadow_fill, icon_shadow_x, icon_shadow_y, icon_shadow_blur])) < 4:
raise click.ClickException("--icon-shadow-* options cannot be partially set.")
icon_paths = map(pathlib.Path, icon_paths)
icon_paths = map(get_svgs, icon_paths)
icon_paths = sum(icon_paths, start=[])
output_dir = pathlib.Path(output_dir)
bg_doc = bs4.BeautifulSoup(bg_file, features="lxml-xml")
bg = bg_doc.svg
icon_paths = map(pathlib.Path, icon_paths)
for icon_path in icon_paths:
icon_path: pathlib.Path
output_svg_path = output_dir.joinpath(f"{icon_path.stem}.svg")
output_png_path = output_dir.joinpath(f"{icon_path.stem}.png")
icon_svgs = get_svgs(icon_path)
with open(icon_path) as icon_file:
click.echo(icon_path, nl=False)
for icon_svg in icon_svgs:
icon_svg: pathlib.Path
relative_path = icon_svg.relative_to(icon_path)
output_svg_path = output_dir.joinpath(f"{relative_path.parent}/{relative_path.stem}.svg")
output_png_path = output_dir.joinpath(f"{relative_path.parent}/{relative_path.stem}.png")
output_svg_path.parent.mkdir(exist_ok=True, parents=True)
with open(icon_svg) as icon_file:
click.echo(icon_svg, nl=False)
icon_doc = bs4.BeautifulSoup(icon_file, features="lxml-xml")
icon = icon_doc.svg
icon.path.attrs["fill"] = icon_fill