From c776ae7aeffcb119ff6d26dd2a2ced97fb7b4ff1 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Thu, 4 Feb 2021 20:20:21 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Cleanup=20&=20extra=20args=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- builder/applbuild/configure.py | 10 ++++-- builder/applbuild/generator.py | 25 +++++---------- builder/build.py | 57 ++++++++++++++++++++++++++++++++-- 3 files changed, 69 insertions(+), 23 deletions(-) diff --git a/builder/applbuild/configure.py b/builder/applbuild/configure.py index 26975ae..94d0ff6 100644 --- a/builder/applbuild/configure.py +++ b/builder/applbuild/configure.py @@ -24,16 +24,20 @@ def get_config(bitmaps_dir: LikePath, **kwargs) -> Dict[str, Any]: :bitmaps_dir: (str | Path) Path to .png file's directory. + Keywords Args: - :x_sizes: (List[Tuple[int, int]] | Tuple[int, int]) List or Tuple of xcursor sizes. + :x_sizes: (List[Size] | Size) List of sizes or single size for xcursors. + + :win_canvas_size: (Size) Windows cursor's canvas size. + + :win_size: (Size) Size for Windows cursor. - :win_size: (Tuple[int, int]) Single size for Windows cursor. Example: ```python - get_config("./bitmaps", x_sizes=[(24, 24), (32, 32)], win_size=(32, 32)) + get_config("./bitmaps", x_sizes=[(24, 24), (32, 32)], win_canvas_size=(32, 32), win_size=(24, 24)) ``` """ diff --git a/builder/applbuild/generator.py b/builder/applbuild/generator.py index a4a7b13..6e28d4d 100644 --- a/builder/applbuild/generator.py +++ b/builder/applbuild/generator.py @@ -7,27 +7,22 @@ from typing import Any, Dict from clickgen.builders import WindowsCursor, XCursor from clickgen.core import CursorAlias from clickgen.packagers import WindowsPackager, XPackager -from clickgen.util import LikePath -from applbuild.configure import get_config from applbuild.constants import AUTHOR, COMMENT, THEME_NAME, URL from applbuild.symlinks import add_missing_xcursor def xbuild( - bitmaps_dir: LikePath, + config: Dict[str, Dict[str, Any]], x_out_dir: Path, ) -> None: """Build `macOSBigSur` cursor theme for only `X11`(UNIX) platform. - :bitmaps_dir: (str | Path) Path to .png file's directory. + :config: (Dict) `macOSBigSur` configuration. :x_out_dir: (Path) Path to the output directory, Where the `X11` cursor theme package will generate. It also creates a directory if not exists. """ - config: Dict[str, Dict[str, Any]] = get_config(bitmaps_dir) - - # Building for _, item in config.items(): png = item.get("png") hotspot = item.get("hotspot") @@ -43,17 +38,14 @@ def xbuild( XPackager(x_out_dir, THEME_NAME, COMMENT) -def wbuild(bitmaps_dir: LikePath, win_out_dir: Path) -> None: +def wbuild(config: Dict[str, Dict[str, Any]], win_out_dir: Path) -> None: """Build `macOSBigSur` cursor theme for only `Windows` platforms. - :bitmaps_dir: (str | Path) Path to .png file's directory. + :config: (Dict) `macOSBigSur` configuration. :win_out_dir: (Path) Path to the output directory, Where the `Windows` cursor theme package will generate. It also creates a directory if not exists. """ - config: Dict[str, Dict[str, Any]] = get_config(bitmaps_dir) - - # Building for _, item in config.items(): png = item.get("png") hotspot = item.get("hotspot") @@ -79,10 +71,12 @@ def wbuild(bitmaps_dir: LikePath, win_out_dir: Path) -> None: WindowsPackager(win_out_dir, THEME_NAME, COMMENT, AUTHOR, URL) -def build(bitmaps_dir: LikePath, x_out_dir: Path, win_out_dir: Path) -> None: +def build( + config: Dict[str, Dict[str, Any]], x_out_dir: Path, win_out_dir: Path +) -> None: """Build `macOSBigSur` cursor theme for `X11` & `Windows` platforms. - :bitmaps_dir: (str | Path) Path to .png file's directory. + :config: (Dict) `macOSBigSur` configuration. :x_out_dir: (Path) Path to the output directory, Where the `X11` cursor theme package will generate. It also creates a directory if not exists. @@ -102,9 +96,6 @@ def build(bitmaps_dir: LikePath, x_out_dir: Path, win_out_dir: Path) -> None: print(f"Building '{win_cfg.stem}' Windows Cursor...") WindowsCursor.create(win_cfg, win_out_dir) - config: Dict[str, Dict[str, Any]] = get_config(bitmaps_dir) - - # Building for _, item in config.items(): png = item.get("png") hotspot = item.get("hotspot") diff --git a/builder/build.py b/builder/build.py index 726c7cc..6e3a5a2 100644 --- a/builder/build.py +++ b/builder/build.py @@ -3,6 +3,7 @@ import argparse from pathlib import Path +from applbuild.configure import get_config from applbuild.generator import build, wbuild, xbuild @@ -44,16 +45,66 @@ parser.add_argument( ) +parser.add_argument( + "-xs", + "--xsizes", + dest="xsizes", + metavar="SIZE", + nargs="+", + default=[ + 22, + 24, + 28, + 32, + 40, + 48, + 56, + 64, + 72, + 80, + 88, + 96, + ], + type=int, + help="Set pixel-size for xcursor. (default: %(default)s)", +) + + +parser.add_argument( + "-ws", + "--win-size", + dest="win_size", + metavar="SIZE", + default=24, + type=int, + help="Set pixel-size for Windows cursors. (default: %(default)s)", +) + + +parser.add_argument( + "-wcs", + "--win-canvas-size", + dest="win_sizes", + metavar="SIZE", + default=32, + type=int, + help="Set pixel-size for Windows cursor's canvas. (default: %(default)s)", +) + # Preparing build args = parser.parse_args() bitmaps_dir = Path(args.png_dir) + x_out_dir = Path(args.out_dir) / "macOSBigSur" win_out_dir = Path(args.out_dir) / "macOSBigSur_Windows" + +config = get_config(bitmaps_dir) + if args.platform == "unix": - xbuild(bitmaps_dir, x_out_dir) + xbuild(config, x_out_dir) elif args.platform == "windows": - wbuild(bitmaps_dir, win_out_dir) + wbuild(config, win_out_dir) else: - build(bitmaps_dir, x_out_dir, win_out_dir) + build(config, x_out_dir, win_out_dir)