feat: add dup feature
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import PIL.Image
|
import PIL.Image
|
||||||
from .utils import Artifact, ArtifactFile
|
from .utils import Artifact, ArtifactFile
|
||||||
@@ -23,3 +24,7 @@ def load_artifact(p: Path) -> ArtifactFile:
|
|||||||
def save_artifact(art: Artifact, p: Path) -> None:
|
def save_artifact(art: Artifact, p: Path) -> None:
|
||||||
logging.info("Saving artifact: %s", p)
|
logging.info("Saving artifact: %s", p)
|
||||||
art.save(p, format="PNG")
|
art.save(p, format="PNG")
|
||||||
|
|
||||||
|
|
||||||
|
def dup_artifact(src: Path, dst: Path) -> None:
|
||||||
|
shutil.copyfile(src, dst)
|
||||||
|
|||||||
@@ -285,6 +285,15 @@ class AdvancedContext:
|
|||||||
dst = self.__fd_artifact(hw, kind, name)
|
dst = self.__fd_artifact(hw, kind, name)
|
||||||
artio.save_artifact(thumbnail, dst)
|
artio.save_artifact(thumbnail, dst)
|
||||||
|
|
||||||
|
def dup_fd_artifact(
|
||||||
|
self, src_kind: FdContext, src_name: str, dst_kind: FdContext, dst_name: str
|
||||||
|
) -> None:
|
||||||
|
for hw in _FD_THUMBNAIL_HWS:
|
||||||
|
artio.dup_artifact(
|
||||||
|
self.__fd_artifact(hw, src_kind, src_name),
|
||||||
|
self.__fd_artifact(hw, dst_kind, dst_name),
|
||||||
|
)
|
||||||
|
|
||||||
def __win_artifact(self, kind: WinCategory, name: str) -> Path:
|
def __win_artifact(self, kind: WinCategory, name: str) -> Path:
|
||||||
return self.__context.output_artifact(_ART_WIN, str(kind), f"{name}.ico")
|
return self.__context.output_artifact(_ART_WIN, str(kind), f"{name}.ico")
|
||||||
|
|
||||||
@@ -299,6 +308,14 @@ class AdvancedContext:
|
|||||||
)
|
)
|
||||||
artrender.render_ico(art, self.__win_artifact(kind, name))
|
artrender.render_ico(art, self.__win_artifact(kind, name))
|
||||||
|
|
||||||
|
def dup_win_artifact(
|
||||||
|
self, src_kind: WinCategory, src_name: str, dst_kind: WinCategory, dst_name: str
|
||||||
|
) -> None:
|
||||||
|
artio.dup_artifact(
|
||||||
|
self.__win_artifact(src_kind, src_name),
|
||||||
|
self.__win_artifact(dst_kind, dst_name),
|
||||||
|
)
|
||||||
|
|
||||||
def __mac_artifact(self, kind: MacCategory, name: str) -> Path:
|
def __mac_artifact(self, kind: MacCategory, name: str) -> Path:
|
||||||
return self.__context.output_artifact(_ART_MAC, str(kind), f"{name}.icns")
|
return self.__context.output_artifact(_ART_MAC, str(kind), f"{name}.icns")
|
||||||
|
|
||||||
@@ -311,4 +328,12 @@ class AdvancedContext:
|
|||||||
logging.info("Saving macOS-only artifact with kind %s and name %s.", kind, name)
|
logging.info("Saving macOS-only artifact with kind %s and name %s.", kind, name)
|
||||||
artrender.render_icns(art, self.__mac_artifact(kind, name))
|
artrender.render_icns(art, self.__mac_artifact(kind, name))
|
||||||
|
|
||||||
|
def dup_mac_artifact(
|
||||||
|
self, src_kind: MacCategory, src_name: str, dst_kind: MacCategory, dst_name: str
|
||||||
|
) -> None:
|
||||||
|
artio.dup_artifact(
|
||||||
|
self.__mac_artifact(src_kind, src_name),
|
||||||
|
self.__mac_artifact(dst_kind, dst_name),
|
||||||
|
)
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user