Cleanup & extra args added

This commit is contained in:
ful1e5 2021-02-04 20:20:21 +05:30
parent d6f9ad8750
commit c776ae7aef
3 changed files with 69 additions and 23 deletions

View file

@ -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))
```
"""

View file

@ -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")

View file

@ -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)