From 80738d1254057158a0557f961e57fbe33c1c5b6b Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Thu, 27 Aug 2026 13:04:12 +0800 Subject: [PATCH] feat: pre-create all essential directories in advanced context --- .../assemblicon/context.py | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/tool/src/aurora_iconset_builder/assemblicon/context.py b/tool/src/aurora_iconset_builder/assemblicon/context.py index 1de8b22..054525e 100644 --- a/tool/src/aurora_iconset_builder/assemblicon/context.py +++ b/tool/src/aurora_iconset_builder/assemblicon/context.py @@ -100,9 +100,9 @@ _ART_MAC: str = "macos" _DEFAULT_SVG_CONFIG = artrender.SvgConfig(VANILLA_ARTIFACT_HW, VANILLA_ARTIFACT_HW) _DEFAULT_BLD_CONFIG = artrender.BlenderConfig(VANILLA_ARTIFACT_HW, VANILLA_ARTIFACT_HW) -# TODO: For easy testing, we only build 48x48. +# TODO: For easy testing, we only build 32x32 and 48x48. # Enable full generation after testing. -_FD_THUMBNAIL_HWS: tuple[int, ...] = (48,) +_FD_THUMBNAIL_HWS: tuple[int, ...] = (32, 48) # _FD_THUMBNAIL_HWS: tuple[int, ...] = (16, 32, 48, 64, 128, 256) @@ -112,7 +112,30 @@ class AdvancedContext: def __init__(self, ctx: Context) -> None: self.__context = ctx - # construct basic layout of temporary directory and output directory. + # construct basic layout of temporary directory + self.__context.temporary_artifact(_TEMP_USER_DIR).mkdir( + parents=True, exist_ok=True + ) + self.__context.temporary_artifact(_TEMP_LIB_DIR, _TEMP_LIB_ALLOC_DIR).mkdir( + parents=True, exist_ok=True + ) + self.__context.temporary_artifact(_TEMP_LIB_DIR, _TEMP_LIB_STABLE_DIR).mkdir( + parents=True, exist_ok=True + ) + # and output directory + for hw in _FD_THUMBNAIL_HWS: + for kind in FdContext: + self.__context.output_artifact(f"{hw}x{hw}", str(kind)).mkdir( + parents=True, exist_ok=True + ) + for kind in WinCategory: + self.__context.output_artifact(_ART_WIN, str(kind)).mkdir( + parents=True, exist_ok=True + ) + for kind in MacCategory: + self.__context.output_artifact(_ART_MAC, str(kind)).mkdir( + parents=True, exist_ok=True + ) def __enter__(self) -> "AdvancedContext": return self @@ -207,7 +230,10 @@ class AdvancedContext: self.__intern_render_svg(src, dst, cfg) def render_svg_then_load( - self, src: Path, dst: Optional[Path] = None, cfg: SvgConfig = _DEFAULT_SVG_CONFIG + self, + src: Path, + dst: Optional[Path] = None, + cfg: SvgConfig = _DEFAULT_SVG_CONFIG, ) -> Artifact: """ Render given SVG to PNG file, then load it directly. @@ -248,7 +274,10 @@ class AdvancedContext: self.__intern_render_blender(src, dst, cfg) def render_blender_then_load( - self, src: Path, dst: Optional[Path] = None, cfg: BlenderConfig = _DEFAULT_BLD_CONFIG + self, + src: Path, + dst: Optional[Path] = None, + cfg: BlenderConfig = _DEFAULT_BLD_CONFIG, ) -> Artifact: """ Render given Blender composition to PNG file, then load it directly.