🔧 configured dynamic comment & theme name

This commit is contained in:
ful1e5 2021-08-24 16:39:23 +05:30
parent c2946a4a42
commit 174c76f618
4 changed files with 47 additions and 34 deletions

View file

@ -5,13 +5,14 @@ import argparse
from pathlib import Path from pathlib import Path
from src.configure import get_config from src.configure import get_config
from src.generator import build, wbuild, xbuild from src.generator import Info, build, wbuild, xbuild
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
prog="apple_builder", prog="apple_builder",
description="'macOSBigSur' cursor build python script.", description="'macOSBigSur' cursor build python script.",
) )
# Positional Args. # Positional Args.
parser.add_argument( parser.add_argument(
"platform", "platform",
@ -95,9 +96,10 @@ parser.add_argument(
args = parser.parse_args() args = parser.parse_args()
bitmaps_dir = Path(args.png_dir) bitmaps_dir = Path(args.png_dir)
name = bitmaps_dir.stem
x_out_dir = Path(args.out_dir) / "macOSBigSur" x_out_dir = Path(args.out_dir) / name
win_out_dir = Path(args.out_dir) / "macOSBigSur_Windows" win_out_dir = Path(args.out_dir) / f"{name}-Windows"
# Windows Canvas & Cursor sizes # Windows Canvas & Cursor sizes
win_size: int = args.win_size win_size: int = args.win_size
@ -105,17 +107,20 @@ win_canvas_size: int = args.win_canvas_size
if win_canvas_size < win_size: if win_canvas_size < win_size:
win_canvas_size = win_size win_canvas_size = win_size
print(f"Getting '{name}' bitmaps ready for build...")
config = get_config( config = get_config(
bitmaps_dir, bitmaps_dir,
x_sizes=args.xsizes, x_sizes=args.xsizes,
win_canvas_size=win_canvas_size, win_canvas_size=args.win_canvas_size,
win_size=win_size, win_size=args.win_size,
) )
info = Info(name=name, comment=f"{name} Cursors")
if args.platform == "unix": if args.platform == "unix":
xbuild(config, x_out_dir) xbuild(config, x_out_dir, info)
elif args.platform == "windows": elif args.platform == "windows":
wbuild(config, win_out_dir) wbuild(config, win_out_dir, info)
else: else:
build(config, x_out_dir, win_out_dir) build(config, x_out_dir, win_out_dir, info)

View file

@ -4,7 +4,6 @@
from typing import Any, Dict, Tuple, TypeVar from typing import Any, Dict, Tuple, TypeVar
from clickgen.util import PNGProvider from clickgen.util import PNGProvider
from .constants import WIN_CURSORS_CFG, WIN_DELAY, X_CURSORS_CFG, X_DELAY from .constants import WIN_CURSORS_CFG, WIN_DELAY, X_CURSORS_CFG, X_DELAY
X = TypeVar("X") X = TypeVar("X")
@ -15,7 +14,7 @@ def to_tuple(x: X) -> Tuple[X, X]:
def get_config(bitmaps_dir, **kwargs) -> Dict[str, Any]: def get_config(bitmaps_dir, **kwargs) -> Dict[str, Any]:
"""Return configuration of `GoogleDot` pointers. """Return configuration of `macOSBigSur` pointers.
:param bitmaps_dir: Path to .png file's directory. :param bitmaps_dir: Path to .png file's directory.
:type bitmaps_dir: ``str`` or ``pathlib.Path`` :type bitmaps_dir: ``str`` or ``pathlib.Path``

View file

@ -4,8 +4,6 @@
from typing import Dict from typing import Dict
# Info # Info
THEME_NAME = "macOSBigSur"
COMMENT = "macOS Big Sur Pointers"
AUTHOR = "Kaiz Khatri" AUTHOR = "Kaiz Khatri"
URL = "https://github.com/ful1e5/apple_cursor" URL = "https://github.com/ful1e5/apple_cursor"

View file

@ -1,31 +1,42 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""This module provides build methods for ``macOSBigSur``."""
from pathlib import Path from pathlib import Path
from typing import Any, Dict from typing import Any, Dict, NamedTuple
from clickgen.builders import WindowsCursor, XCursor from clickgen.builders import WindowsCursor, XCursor
from clickgen.core import CursorAlias from clickgen.core import CursorAlias
from clickgen.packagers import WindowsPackager, XPackager from clickgen.packagers import WindowsPackager, XPackager
from .constants import AUTHOR, URL
from .constants import AUTHOR, COMMENT, THEME_NAME, URL
from .symlinks import add_missing_xcursor from .symlinks import add_missing_xcursor
def xbuild(config: Dict[str, Dict[str, Any]], x_out_dir: Path) -> None: class Info(NamedTuple):
"""Theme basic information.
:param name: Theme title.
:type name: ``str``
:param comment: quick information about theme.
:type comment: ``str``
"""
name: str
comment: str
def xbuild(config: Dict[str, Dict[str, Any]], x_out_dir: Path, info: Info) -> None:
"""Build `macOSBigSur` cursor theme for only `X11`(UNIX) platform. """Build `macOSBigSur` cursor theme for only `X11`(UNIX) platform.
:param config: `macOSBigSur` configuration. :param config: `macOSBigSur` configuration.
:type config: Dict :type config: ``Dict``
:param x_out_dir: Path to the output directory,\ :param x_out_dir: Path to the output directory,\
Where the `X11` cursor theme package will generate.\ Where the `X11` cursor theme package will generate.\
It also creates a directory if not exists. It also creates a directory if not exists.
:type x_out_dir: Path :type x_out_dir: ``pathlib.Path``
:param info: Content theme name & comment :param info: Content theme name & comment.
:type info: Info :type info: Info
""" """
@ -37,21 +48,21 @@ def xbuild(config: Dict[str, Dict[str, Any]], x_out_dir: Path) -> None:
XCursor.create(x_cfg, x_out_dir) XCursor.create(x_cfg, x_out_dir)
add_missing_xcursor(x_out_dir / "cursors") add_missing_xcursor(x_out_dir / "cursors")
XPackager(x_out_dir, THEME_NAME, COMMENT) XPackager(x_out_dir, info.name, info.comment)
def wbuild(config: Dict[str, Dict[str, Any]], win_out_dir: Path) -> None: def wbuild(config: Dict[str, Dict[str, Any]], win_out_dir: Path, info: Info) -> None:
"""Build `macOSBigSur` cursor theme for only `Windows` platforms. """Build `macOSBigSur` cursor theme for only `Windows` platforms.
:param config: `macOSBigSur` configuration. :param config: `macOSBigSur` configuration.
:type config: Dict :type config: ``Dict``
:param win_out_dir: Path to the output directory,\ :param win_out_dir: Path to the output directory,\
Where the `Windows` cursor theme package will generate.\ Where the `Windows` cursor theme package will generate.\
It also creates a directory if not exists. It also creates a directory if not exists.
:type win_out_dir: Path :type win_out_dir: ``pathlib.Path``
:param info: Content theme name & comment :param info: Content theme name & comment.
:type info: Info :type info: Info
""" """
@ -70,28 +81,28 @@ def wbuild(config: Dict[str, Dict[str, Any]], win_out_dir: Path) -> None:
print(f"Building '{win_cfg.stem}' Windows Cursor...") print(f"Building '{win_cfg.stem}' Windows Cursor...")
WindowsCursor.create(win_cfg, win_out_dir) WindowsCursor.create(win_cfg, win_out_dir)
WindowsPackager(win_out_dir, THEME_NAME, COMMENT, AUTHOR, URL) WindowsPackager(win_out_dir, info.name, info.comment, AUTHOR, URL)
def build( def build(
config: Dict[str, Dict[str, Any]], x_out_dir: Path, win_out_dir: Path config: Dict[str, Dict[str, Any]], x_out_dir: Path, win_out_dir: Path, info: Info
) -> None: ) -> None:
"""Build `macOSBigSur` cursor theme for `X11` & `Windows` platforms. """Build `macOSBigSur` cursor theme for `X11` & `Windows` platforms.
:param config: `macOSBigSur` configuration. :param config: `macOSBigSur` configuration.
:type config: Dict :type config: ``Dict``
:param x_out_dir: Path to the output directory,\ :param x_out_dir: Path to the output directory,\
Where the `X11` cursor theme package will generate.\ Where the `X11` cursor theme package will generate.\
It also creates a directory if not exists. It also creates a directory if not exists.
:type x_out_dir: Path :type x_out_dir: ``pathlib.Path``
:param win_out_dir: Path to the output directory,\ :param win_out_dir: Path to the output directory,\
Where the `Windows` cursor theme package will generate.\ Where the `Windows` cursor theme package will generate.\
It also creates a directory if not exists. It also creates a directory if not exists.
:type win_out_dir: Path :type win_out_dir: ``pathlib.Path``
:param info: Content theme name & comment :param info: Content theme name & comment.
:type info: Info :type info: Info
""" """
@ -115,6 +126,6 @@ def build(
WindowsCursor.create(win_cfg, win_out_dir) WindowsCursor.create(win_cfg, win_out_dir)
add_missing_xcursor(x_out_dir / "cursors") add_missing_xcursor(x_out_dir / "cursors")
XPackager(x_out_dir, THEME_NAME, COMMENT) XPackager(x_out_dir, info.name, info.comment)
WindowsPackager(win_out_dir, THEME_NAME, COMMENT, AUTHOR, URL) WindowsPackager(win_out_dir, info.name, info.comment, AUTHOR, URL)