1
Fork 0
mirror of https://github.com/Steffo99/emblematic.git synced 2024-10-16 06:07:26 +00:00

Reformat code

This commit is contained in:
Steffo 2023-11-19 02:43:24 +01:00
parent d64bb15df0
commit 59289e68af
Signed by: steffo
GPG key ID: 2A24051445686895
4 changed files with 13 additions and 14 deletions

View file

@ -1,7 +1,6 @@
from . import compose
from . import files
__all__ = (
"compose",
"files",

View file

@ -4,13 +4,14 @@ Command-line interface for :mod:`emblematic`.
Implemented with :mod:`click`.
"""
import click
import bs4
import pathlib
import cairosvg
from .files import get_svgs
import bs4
import cairosvg
import click
from .compose import compose_basic
from .files import get_svgs
@click.group()
@ -83,7 +84,7 @@ def basic(bg_file, icon_paths, icon_fill, output_dir, width, height, keep_svg):
icon_doc = bs4.BeautifulSoup(icon_file, features="lxml-xml")
icon = icon_doc.svg
icon.path.attrs["fill"] = icon_fill
click.echo("", nl=False)
svg_doc = compose_basic(background=bg, icon=icon, width=width, height=height).prettify()
@ -91,7 +92,7 @@ def basic(bg_file, icon_paths, icon_fill, output_dir, width, height, keep_svg):
with open(output_svg_path, mode="w") as output_file:
click.echo(output_svg_path, nl=False)
output_file.write(svg_doc)
click.echo("", nl=False)
svg_bytes = bytes(svg_doc, encoding="utf8")
png_bytes = cairosvg.svg2png(bytestring=svg_bytes)
@ -103,6 +104,5 @@ def basic(bg_file, icon_paths, icon_fill, output_dir, width, height, keep_svg):
click.echo()
if __name__ == "__main__":
main()

View file

@ -14,19 +14,19 @@ def compose_basic(background: bs4.Tag, icon: bs4.Tag, width: int, height: int) -
raise ValueError("bg is not a <svg> tag.")
if icon.name != "svg":
raise ValueError("fg is not a <svg> tag.")
background = background.__copy__()
background.attrs["id"] = "emblematic-background"
background.attrs["width"] = "100%"
background.attrs["height"] = "100%"
icon = icon.__copy__()
icon.attrs["id"] = "emblematic-icon"
icon.attrs["width"] = "63%"
icon.attrs["height"] = "63%"
icon.attrs["preserveAspectRatio"] = "xMidYMid meet"
icon.attrs["transform"] = f"translate({width * 0.37 / 2}, {height * 0.37 / 2})"
icon.attrs["transform"] = f"translate({width * 0.37 / 2}, {height * 0.37 / 2})"
doc = bs4.BeautifulSoup(f"""
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {width} {height}">
</svg>
@ -36,7 +36,7 @@ def compose_basic(background: bs4.Tag, icon: bs4.Tag, width: int, height: int) -
container.append(icon)
return doc
__all__ = (
"compose_basic",

View file

@ -13,7 +13,7 @@ def get_svgs(path: pathlib.Path):
raise ValueError("Given path does not exist.")
if not path.is_dir():
return [path]
return list(path.glob("**/*.svg"))