summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcheck.py10
-rwxr-xr-xicon/convert.py66
2 files changed, 74 insertions, 2 deletions
diff --git a/check.py b/check.py
index 858309c..9c45f4d 100755
--- a/check.py
+++ b/check.py
@@ -6,9 +6,9 @@ import subprocess
import shutil
import sys
-
SCRIPT = pathlib.Path(__file__).resolve()
ROOT = SCRIPT.parent
+ICON = ROOT / "icon"
def main() -> None:
@@ -67,7 +67,13 @@ def black() -> None:
def get_python_files() -> tuple[pathlib.Path, ...]:
- return tuple(ROOT.glob("*.py"))
+ files: list[pathlib.Path] = []
+
+ for directory in (ROOT, ICON):
+ for file in directory.glob("*.py"):
+ files.append(file)
+
+ return tuple(files)
def flutter_analyze() -> None:
diff --git a/icon/convert.py b/icon/convert.py
new file mode 100755
index 0000000..b550709
--- /dev/null
+++ b/icon/convert.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python3
+
+
+import argparse
+import dataclasses
+import os
+import pathlib
+import subprocess
+import sys
+
+DESCRIPTION = "Script to convert main icon file to all required formats"
+SCRIPT = pathlib.Path(__file__).resolve()
+ICON = SCRIPT.parent
+MAIN = ICON / "main.svg"
+ANDROID = ICON / "android"
+
+
+def main() -> None:
+ _ = Arguments.from_list(sys.argv)
+
+ os.makedirs(ANDROID, exist_ok=True)
+ inkscape(MAIN, ANDROID / "default.png")
+ inkscape(MAIN, ANDROID / "foreground.png", ids=("foreground",))
+ inkscape(MAIN, ANDROID / "background.png", ids=("background",))
+
+
+@dataclasses.dataclass(frozen=True, kw_only=True)
+class Arguments:
+
+ @staticmethod
+ def from_list(args: list[str]) -> "Arguments":
+ parser = argparse.ArgumentParser(description=DESCRIPTION)
+
+ parser.parse_args(args[1:])
+
+ return Arguments()
+
+
+def inkscape(
+ source: pathlib.Path,
+ sink: pathlib.Path,
+ ids: tuple[str, ...] = ("foreground", "background"),
+ width: int = 1024,
+ height: int = 1024,
+) -> None:
+ subprocess.run(
+ (
+ # fmt: off
+ "inkscape", str(source),
+ "--export-filename", str(sink),
+ "--export-area-page",
+ "--export-id", ";".join(ids),
+ "--export-width", str(width),
+ "--export-height", str(height),
+ "--export-id-only",
+ # fmt: on
+ ),
+ check=True,
+ shell=False,
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL,
+ )
+
+
+if __name__ == "__main__":
+ main()