🔗 Relative imports inside applbuild modules

This commit is contained in:
ful1e5 2021-04-23 16:34:21 +05:30
parent 6558781771
commit e886686749
3 changed files with 28 additions and 26 deletions

View file

@ -1,12 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pathlib import Path
from typing import Any, Dict, Tuple, TypeVar, Union
from typing import Any, Dict, Tuple, TypeVar
from applbuild.constants import WIN_CURSORS_CFG, WIN_DELAY, X_CURSORS_CFG, X_DELAY
from clickgen.util import PNGProvider
from .constants import WIN_CURSORS_CFG, WIN_DELAY, X_CURSORS_CFG, X_DELAY
X = TypeVar("X")
@ -14,29 +14,31 @@ def to_tuple(x: X) -> Tuple[X, X]:
return (x, x)
def get_config(bitmaps_dir: Union[str, Path], **kwargs) -> Dict[str, Any]:
"""Return configuration of `macOSBigSur` pointers.
def get_config(bitmaps_dir, **kwargs) -> Dict[str, Any]:
"""Return configuration of `GoogleDot` pointers.
:param bitmaps_dir: Path to .png file's directory.
:type bitmaps_dir: Union[str, Path]
:type bitmaps_dir: ``str`` or ``pathlib.Path``
:param x_sizes: List of pixel-sizes for xcursors.
:type x_sizes: List[int]
:param **kwargs:
See below
:param win_canvas_size: Windows cursor's canvas pixel-size.
:type win_canvas_size: int
:param win_size: Pixel-size for Windows cursor.
:type win_size: int
:Keyword Arguments:
* *x_sizes* (``List[int]``) --
List of pixel-sizes for xcursors.
* *win_canvas_size* (``int``) --
Windows cursor's canvas pixel-size.
* *win_size* (``int``) --
Pixel-size for Windows cursor.
Example:
```python
get_config(
"./bitmaps",
x_sizes=[(24, 24), (32, 32)],
win_canvas_size=(32, 32),
win_size=(24, 24),
bitmaps_dir="./bitmaps",
x_sizes=[24, 28, 32],
win_canvas_size=32,
win_size=24,
)
```
"""
@ -49,6 +51,7 @@ def get_config(bitmaps_dir: Union[str, Path], **kwargs) -> Dict[str, Any]:
for size in raw_x_sizes:
x_sizes.append(to_tuple(size))
png_provider = PNGProvider(bitmaps_dir)
config: Dict[str, Any] = {}
for key, item in X_CURSORS_CFG.items():
@ -57,13 +60,12 @@ def get_config(bitmaps_dir: Union[str, Path], **kwargs) -> Dict[str, Any]:
hotspot: Tuple[int, int] = (x_hot, y_hot)
delay: int = int(item.get("delay", X_DELAY))
pngs = PNGProvider(bitmaps_dir).get(key)
if not pngs:
raise FileNotFoundError(f"{key} not found in {bitmaps_dir}")
png = png_provider.get(key)
if not png:
raise FileNotFoundError(f"{key} not found")
data = {
"png": pngs,
"png": png,
"x_sizes": x_sizes,
"hotspot": hotspot,
"delay": delay,
@ -94,7 +96,6 @@ def get_config(bitmaps_dir: Union[str, Path], **kwargs) -> Dict[str, Any]:
"win_size": win_size,
"win_delay": win_delay,
}
else:
config[key] = data

View file

@ -6,12 +6,13 @@
from pathlib import Path
from typing import Any, Dict
from applbuild.constants import AUTHOR, COMMENT, THEME_NAME, URL
from applbuild.symlinks import add_missing_xcursor
from clickgen.builders import WindowsCursor, XCursor
from clickgen.core import CursorAlias
from clickgen.packagers import WindowsPackager, XPackager
from .constants import AUTHOR, COMMENT, THEME_NAME, URL
from .symlinks import add_missing_xcursor
def xbuild(config: Dict[str, Dict[str, Any]], x_out_dir: Path) -> None:
"""Build `macOSBigSur` cursor theme for only `X11`(UNIX) platform.

View file

@ -12,7 +12,7 @@ def add_missing_xcursor(directory: Union[str, Path]) -> None:
"""Add missing `XCursor` to the Unix cursor package.
:param directory: directory where XCursors are available.
:type directory: Union[str, Path]
:type directory: ``str`` or ``pathlib.Path``
"""
symlinks: List[Dict[str, Union[str, List[str]]]] = [