mirror of
https://github.com/ful1e5/apple_cursor.git
synced 2025-05-24 20:14:37 -04:00
👔 Compact code for generator.py
This commit is contained in:
parent
c152187bb8
commit
580b8d7f52
1 changed files with 49 additions and 60 deletions
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""This module provides build methods for ``macOSBigSur``."""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict
|
||||
|
||||
|
@ -11,29 +13,25 @@ from clickgen.core import CursorAlias
|
|||
from clickgen.packagers import WindowsPackager, XPackager
|
||||
|
||||
|
||||
def xbuild(
|
||||
config: Dict[str, Dict[str, Any]],
|
||||
x_out_dir: Path,
|
||||
) -> None:
|
||||
def xbuild(config: Dict[str, Dict[str, Any]], x_out_dir: Path) -> None:
|
||||
"""Build `macOSBigSur` cursor theme for only `X11`(UNIX) platform.
|
||||
|
||||
:param config: `macOSBigSur` configuration.
|
||||
:type config: Dict[str, Dict[str, Any]]
|
||||
:type config: Dict
|
||||
|
||||
:param x_out_dir: Path to the output directory, \
|
||||
Where the `X11` cursor theme package will\
|
||||
generate. It also creates a directory if not exists.
|
||||
:param x_out_dir: Path to the output directory,\
|
||||
Where the `X11` cursor theme package will generate.\
|
||||
It also creates a directory if not exists.
|
||||
:type x_out_dir: Path
|
||||
|
||||
:param info: Content theme name & comment
|
||||
:type info: Info
|
||||
"""
|
||||
|
||||
for _, item in config.items():
|
||||
png = item["png"]
|
||||
hotspot = item["hotspot"]
|
||||
x_sizes = item["x_sizes"]
|
||||
delay = item["delay"]
|
||||
with CursorAlias.from_bitmap(item["png"], item["hotspot"]) as alias:
|
||||
x_cfg = alias.create(item["x_sizes"], item["delay"])
|
||||
|
||||
with CursorAlias.from_bitmap(png, hotspot) as alias:
|
||||
x_cfg = alias.create(x_sizes, delay)
|
||||
print(f"Building '{x_cfg.stem}' XCursor...")
|
||||
XCursor.create(x_cfg, x_out_dir)
|
||||
|
||||
|
@ -45,33 +43,29 @@ def wbuild(config: Dict[str, Dict[str, Any]], win_out_dir: Path) -> None:
|
|||
"""Build `macOSBigSur` cursor theme for only `Windows` platforms.
|
||||
|
||||
:param config: `macOSBigSur` configuration.
|
||||
:type config: Dict[str, Dict[str, Any]]
|
||||
:type config: Dict
|
||||
|
||||
:param win_out_dir: Path to the output directory, \
|
||||
Where the `Windows` cursor theme package will\
|
||||
generate. It also creates a directory if not exists.
|
||||
:param win_out_dir: Path to the output directory,\
|
||||
Where the `Windows` cursor theme package will generate.\
|
||||
It also creates a directory if not exists.
|
||||
:type win_out_dir: Path
|
||||
|
||||
:param info: Content theme name & comment
|
||||
:type info: Info
|
||||
"""
|
||||
|
||||
for _, item in config.items():
|
||||
png = item["png"]
|
||||
hotspot = item["hotspot"]
|
||||
x_sizes = item["x_sizes"]
|
||||
delay = item["delay"]
|
||||
|
||||
with CursorAlias.from_bitmap(png, hotspot) as alias:
|
||||
alias.create(x_sizes, delay)
|
||||
with CursorAlias.from_bitmap(item["png"], item["hotspot"]) as alias:
|
||||
alias.create(item["x_sizes"], item["delay"])
|
||||
|
||||
if item.get("win_key"):
|
||||
position = item["position"]
|
||||
win_size = item["win_size"]
|
||||
win_key = item["win_key"]
|
||||
canvas_size = item["canvas_size"]
|
||||
win_delay = item["win_delay"]
|
||||
|
||||
win_cfg = alias.reproduce(
|
||||
win_size, canvas_size, position, delay=win_delay
|
||||
).rename(win_key)
|
||||
size=item["win_size"],
|
||||
canvas_size=item["canvas_size"],
|
||||
position=item["position"],
|
||||
delay=item["win_delay"],
|
||||
).rename(item["win_key"])
|
||||
|
||||
print(f"Building '{win_cfg.stem}' Windows Cursor...")
|
||||
WindowsCursor.create(win_cfg, win_out_dir)
|
||||
|
||||
|
@ -84,45 +78,40 @@ def build(
|
|||
"""Build `macOSBigSur` cursor theme for `X11` & `Windows` platforms.
|
||||
|
||||
:param config: `macOSBigSur` configuration.
|
||||
:type config: Dict[str, Dict[str, Any]]
|
||||
:type config: Dict
|
||||
|
||||
:param x_out_dir: Path to the output directory, \
|
||||
Where the `X11` cursor theme package will\
|
||||
generate. It also creates a directory if not exists.
|
||||
:param x_out_dir: Path to the output directory,\
|
||||
Where the `X11` cursor theme package will generate.\
|
||||
It also creates a directory if not exists.
|
||||
:type x_out_dir: Path
|
||||
|
||||
:param win_out_dir: Path to the output directory, \
|
||||
Where the `Windows` cursor theme package will\
|
||||
generate. It also creates a directory if not exists.
|
||||
:param win_out_dir: Path to the output directory,\
|
||||
Where the `Windows` cursor theme package will generate.\
|
||||
It also creates a directory if not exists.
|
||||
:type win_out_dir: Path
|
||||
|
||||
:param info: Content theme name & comment
|
||||
:type info: Info
|
||||
"""
|
||||
|
||||
def win_build(item: Dict[str, Any], alias: CursorAlias) -> None:
|
||||
position = item["position"]
|
||||
win_size = item["win_size"]
|
||||
win_key = item["win_key"]
|
||||
canvas_size = item["canvas_size"]
|
||||
win_delay = item["win_delay"]
|
||||
|
||||
win_cfg = alias.reproduce(
|
||||
win_size, canvas_size, position, delay=win_delay
|
||||
).rename(win_key)
|
||||
print(f"Building '{win_cfg.stem}' Windows Cursor...")
|
||||
WindowsCursor.create(win_cfg, win_out_dir)
|
||||
|
||||
for _, item in config.items():
|
||||
png = item["png"]
|
||||
hotspot = item["hotspot"]
|
||||
x_sizes = item["x_sizes"]
|
||||
delay = item["delay"]
|
||||
|
||||
with CursorAlias.from_bitmap(png, hotspot) as alias:
|
||||
x_cfg = alias.create(x_sizes, delay)
|
||||
with CursorAlias.from_bitmap(item["png"], item["hotspot"]) as alias:
|
||||
x_cfg = alias.create(item["x_sizes"], item["delay"])
|
||||
|
||||
print(f"Building '{x_cfg.stem}' XCursor...")
|
||||
XCursor.create(x_cfg, x_out_dir)
|
||||
|
||||
if item.get("win_key"):
|
||||
win_build(item, alias)
|
||||
win_cfg = alias.reproduce(
|
||||
size=item["win_size"],
|
||||
canvas_size=item["canvas_size"],
|
||||
position=item["position"],
|
||||
delay=item["win_delay"],
|
||||
).rename(item["win_key"])
|
||||
|
||||
print(f"Building '{win_cfg.stem}' Windows Cursor...")
|
||||
WindowsCursor.create(win_cfg, win_out_dir)
|
||||
|
||||
add_missing_xcursor(x_out_dir / "cursors")
|
||||
XPackager(x_out_dir, THEME_NAME, COMMENT)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue