From 8d1c9acd9a51c7dc87b90f5db260a78e33e40015 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Fri, 5 Mar 2021 16:17:34 +0530 Subject: [PATCH 01/53] =?UTF-8?q?=E2=9A=A1=20#23=20Fix=20Cursors=20not=20a?= =?UTF-8?q?vailable=20Linux=20Mint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/packagers.py | 6 +++--- tests/test_packagers.py | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/clickgen/packagers.py b/clickgen/packagers.py index 2dfd7d83..09fdb860 100644 --- a/clickgen/packagers.py +++ b/clickgen/packagers.py @@ -3,13 +3,13 @@ from pathlib import Path from string import Template -from typing import Dict, Iterator, List, Optional, Set +from typing import Dict, Iterator, Optional, Set # --- X11 THEME_FILES_TEMPLATES: Dict[str, Template] = { - "cursor.theme": Template('[Icon Theme]\nName=$theme_name\nInherits="hicolor"'), + "cursor.theme": Template('[Icon Theme]\nName=$theme_name\nInherits="$theme_name"'), "index.theme": Template( '[Icon Theme]\nName=$theme_name\nComment=$comment\nInherits="hicolor"' ), @@ -151,4 +151,4 @@ def WindowsPackager( # Store install.inf file install_inf: Path = directory / "install.inf" - install_inf.write_text(data) \ No newline at end of file + install_inf.write_text(data) diff --git a/tests/test_packagers.py b/tests/test_packagers.py index 80681a9d..6c83c000 100644 --- a/tests/test_packagers.py +++ b/tests/test_packagers.py @@ -18,7 +18,7 @@ def test_XPackger(image_dir: Path) -> None: assert idx_theme.exists() is True with cur_theme.open() as f: - assert f.readlines() == ["[Icon Theme]\n", "Name=test\n", 'Inherits="hicolor"'] + assert f.readlines() == ["[Icon Theme]\n", "Name=test\n", 'Inherits="test"'] with idx_theme.open() as f: assert f.readlines() == [ @@ -153,8 +153,8 @@ def test_WindowsPackager_without_website_url( shutil.rmtree(d) -def test_WindowsPackager_with_website_url( +def test_WindowsPackager_with_website_url( tmpdir_factory: pytest.TempdirFactory, ) -> None: d = Path(tmpdir_factory.mktemp("test_image")) @@ -174,7 +174,9 @@ def test_WindowsPackager_with_website_url( create_test_cursor(d, "Unavailiable.cur") create_test_cursor(d, "Alternate.cur") - WindowsPackager(d, theme_name="test", comment="testing", author="😎",website_url="testing.test") + WindowsPackager( + d, theme_name="test", comment="testing", author="😎", website_url="testing.test" + ) install_file = d / "install.inf" @@ -199,4 +201,4 @@ def test_WindowsPackager_with_website_url( assert "testing.test" in data - shutil.rmtree(d) \ No newline at end of file + shutil.rmtree(d) From 52819fb53596b57275c36ba4dc34cc2f0e3c5e86 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Fri, 5 Mar 2021 17:10:50 +0530 Subject: [PATCH 02/53] =?UTF-8?q?=E2=9C=85=20Linting=20&=20typing=20fixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/core.py | 39 +++++++++++++++++++------------------- clickgen/core.pyi | 48 +++++++++++++++-------------------------------- clickgen/util.py | 27 ++++++++++++++------------ clickgen/util.pyi | 2 +- 4 files changed, 51 insertions(+), 65 deletions(-) diff --git a/clickgen/core.py b/clickgen/core.py index d61b402d..73589eaa 100644 --- a/clickgen/core.py +++ b/clickgen/core.py @@ -5,14 +5,15 @@ from copy import deepcopy from pathlib import Path from tempfile import mkdtemp -from typing import List, Literal, Optional, Tuple, TypeVar, Union +from typing import List, Literal, Optional, Tuple, Union, Dict from PIL import Image as Img from PIL.Image import Image # Typing Size = Tuple[int, int] -LikePath = TypeVar("LikePath", str, Path) +LikePath = Union[str, Path] +LikePathList = Union[List[str], List[Path]] Positions = Literal["top_left", "top_right", "bottom_right", "bottom_right", "center"] @@ -34,7 +35,7 @@ class Bitmap(object): def __init__( self, - png: Union[LikePath, List[LikePath]], + png: Union[LikePath, LikePathList], hotspot: Tuple[int, int], ) -> None: super().__init__() @@ -75,7 +76,7 @@ def __repr__(self) -> str: def __enter__(self) -> "Bitmap": return self - def __exit__(self, *args) -> None: + def __exit__(self) -> None: self.animated = None self.key = None self.size = None @@ -100,7 +101,7 @@ def __set_as_static(self, png: LikePath, hotspot: Tuple[int, int]) -> None: self._set_hotspot(self.png, hotspot) self.animated = False - def __set_as_animated(self, png: List[LikePath], hotspot: Tuple[int, int]) -> None: + def __set_as_animated(self, png: LikePathList, hotspot: Tuple[int, int]) -> None: self.grouped_png = [] for p in png: @@ -246,7 +247,7 @@ def __reproduce(p: Path) -> Image: frame: Image = Img.open(p).resize(size, resample=Img.BICUBIC) x, y = tuple(map(lambda i, j: i - j, canvas_size, size)) - switch = { + switch: Dict[str, Tuple[int, int]] = { "top_left": (0, 0), "top_right": (x, 0), "bottom_left": (0, y), @@ -254,7 +255,7 @@ def __reproduce(p: Path) -> Image: "center": (round(x / 2), round(y / 2)), } - box: Tuple[int, int] = switch.get(position) + box: Tuple[int, int] = switch[position] canvas: Image = Img.new("RGBA", canvas_size, color=(256, 0, 0, 0)) canvas.paste(frame, box=box) @@ -301,17 +302,17 @@ def __rename(png: Path, check: bool) -> Path: def copy(self, path: Optional[LikePath] = None) -> "Bitmap": if not path: - path: Path = Path(mkdtemp(prefix=f"{self.key}__copy__")) + p_obj: Path = Path(mkdtemp(prefix=f"{self.key}__copy__")) else: - path: Path = Path(path) + p_obj: Path = Path(path) - if path.is_file(): - raise NotADirectoryError(f"path '{path.absolute()}' is not a directory") + if p_obj.is_file(): + raise NotADirectoryError(f"path '{p_obj.absolute()}' is not a directory") - path.mkdir(parents=True, exist_ok=True) + p_obj.mkdir(parents=True, exist_ok=True) def __copy(src: Path) -> Path: - dst: Path = path / src.name + dst: Path = p_obj / src.name shutil.copy2(src, dst) return dst @@ -357,7 +358,7 @@ def __repr__(self) -> str: def __enter__(self) -> "CursorAlias": return self - def __exit__(self, *args): + def __exit__(self): self.bitmap.__exit__() self.bitmap = None @@ -379,7 +380,7 @@ def __exit__(self, *args): @classmethod def from_bitmap( cls, - png: Union[LikePath, List[LikePath]], + png: Union[LikePath, LikePathList], hotspot: Tuple[int, int], ) -> "CursorAlias": bmp: Bitmap = Bitmap(png, hotspot) @@ -421,7 +422,7 @@ def __write_alias(lines: List[str]) -> None: self.alias_file = cfg sizes_type_err: str = ( - f"argument 'sizes' should be Tuple[int, int] type or List[Tuple[int, int]]." + "argument 'sizes' should be Tuple[int, int] type or List[Tuple[int, int]]." ) # Multiple sizes @@ -450,9 +451,9 @@ def __write_alias(lines: List[str]) -> None: def check_alias(self) -> None: if not any(self.alias_dir.iterdir()): - raise FileNotFoundError(f"Alias directory is empty or not exists.") + raise FileNotFoundError("Alias directory is empty or not exists.") - def extension(self, ext: Optional[str] = None) -> Union[str, Path]: + def extension(self, ext: Optional[str] = None) -> LikePath: self.check_alias() if ext: new_path: Path = self.alias_file.with_suffix(ext) @@ -466,7 +467,7 @@ def copy(self, dst: Optional[LikePath] = None) -> "CursorAlias": if not dst: dst = mkdtemp(prefix=self.prefix) - dst: Path = Path(dst) + dst = Path(dst) if dst.is_file(): raise NotADirectoryError(f"path '{dst.absolute()}' is not a directory") diff --git a/clickgen/core.pyi b/clickgen/core.pyi index 75361937..a6dbbf21 100644 --- a/clickgen/core.pyi +++ b/clickgen/core.pyi @@ -1,10 +1,10 @@ -from pathlib import Path -from typing import Any, List, Literal, Optional, Tuple, TypeVar, Union - from PIL.Image import Image as Image +from pathlib import Path +from typing import Any, List, Literal, Optional, Tuple, Union Size = Tuple[int, int] -LikePath = TypeVar("LikePath", str, Path) +LikePath = Union[str, Path] +LikePathList = Union[List[str], List[Path]] Positions: Any class Bitmap: @@ -18,23 +18,13 @@ class Bitmap: width: int height: int compress: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] = ... - def __init__( - self, png: Union[LikePath, List[LikePath]], hotspot: Tuple[int, int] - ) -> None: ... + def __init__(self, png: Union[LikePath, LikePathList], hotspot: Tuple[int, int]) -> None: ... def __enter__(self) -> Bitmap: ... - def __exit__(self, *args: Any) -> None: ... - def resize( - self, size: Size, resample: int = ..., save: bool = ... - ) -> Optional[Union[Image, List[Image]]]: ... - def reproduce( - self, - size: Size = ..., - canvas_size: Size = ..., - position: Positions = ..., - save: Any = ..., - ) -> Optional[Union[Image, List[Image]]]: ... + def __exit__(self) -> None: ... + def resize(self, size: Size, resample: int=..., save: bool=...) -> Optional[Union[Image, List[Image]]]: ... + def reproduce(self, size: Size=..., canvas_size: Size=..., position: Positions=..., save: Any=...) -> Optional[Union[Image, List[Image]]]: ... def rename(self, key: str) -> None: ... - def copy(self, path: Optional[LikePath] = ...) -> Bitmap: ... + def copy(self, path: Optional[LikePath]=...) -> Bitmap: ... class CursorAlias: bitmap: Bitmap @@ -44,20 +34,12 @@ class CursorAlias: garbage_dirs: List[Path] = ... def __init__(self, bitmap: Bitmap) -> None: ... def __enter__(self) -> CursorAlias: ... - def __exit__(self, *args: Any) -> None: ... + def __exit__(self) -> None: ... @classmethod - def from_bitmap( - cls: Any, png: Union[LikePath, List[LikePath]], hotspot: Tuple[int, int] - ) -> CursorAlias: ... - def create(self, sizes: Union[Size, List[Size]], delay: int = ...) -> Path: ... + def from_bitmap(cls: Any, png: Union[LikePath, LikePathList], hotspot: Tuple[int, int]) -> CursorAlias: ... + def create(self, sizes: Union[Size, List[Size]], delay: int=...) -> Path: ... def check_alias(self) -> None: ... - def extension(self, ext: Optional[str] = ...) -> Union[str, Path]: ... - def copy(self, dst: Optional[LikePath] = ...) -> CursorAlias: ... + def extension(self, ext: Optional[str]=...) -> LikePath: ... + def copy(self, dst: Optional[LikePath]=...) -> CursorAlias: ... def rename(self, key: str) -> Path: ... - def reproduce( - self, - size: Size = ..., - canvas_size: Size = ..., - position: Positions = ..., - delay: int = ..., - ) -> CursorAlias: ... + def reproduce(self, size: Size=..., canvas_size: Size=..., position: Positions=..., delay: int=...) -> CursorAlias: ... diff --git a/clickgen/util.py b/clickgen/util.py index 565af245..3f632bde 100644 --- a/clickgen/util.py +++ b/clickgen/util.py @@ -30,20 +30,18 @@ def chdir(directory: LikePath): os.chdir(prev_cwd) -def remove_util(p: LikePath) -> None: +def remove_util(p: Union[str, Path]) -> None: """Remove this file, directory or symlink. If Path exits on filesystem. :p: path to directory. """ + p_obj: Path = Path(p) - if isinstance(p, str): - p: Path = Path(p) - - if p.exists(): - if p.is_dir(): - shutil.rmtree(p) + if p_obj.exists(): + if p_obj.is_dir(): + shutil.rmtree(p_obj) else: - p.unlink() + p_obj.unlink() else: pass @@ -77,9 +75,14 @@ def get(self, key: str) -> Union[List[Path], Path]: The only way to sync the directory is, By creating a new instance of the `PNGProvider` class. - :key: `.png` filename without extension. + :key: Without extension it search for multiple files, Else search the key with `.png` extension. """ - r = re.compile(key) + k = key.split(".") + if len(k) == 1: + r = re.compile(fr"^{k[0]}(?:-\d+)?.png$") + else: + r = re.compile(fr"^{k[0]}(?:-\d+)?.{k[1]}$") + matched_pngs = filter(r.match, self.__pngs) paths = list(set(map(lambda x: self.bitmaps_dir / x, matched_pngs))) @@ -93,7 +96,7 @@ def add_missing_xcursors( data: List[Set[str]] = DATA, rename: bool = False, force: bool = False, -) -> bool: +) -> None: if not directory.exists() or not directory.is_dir(): raise NotADirectoryError(directory.absolute()) @@ -103,7 +106,7 @@ def add_missing_xcursors( if force: for xcursor in directory.iterdir(): if xcursor.is_symlink(): - xcursor.unlink(xcursor) + xcursor.unlink(missing_ok=True) xcursors = sorted(directory.iterdir()) diff --git a/clickgen/util.pyi b/clickgen/util.pyi index 146df92e..a8541788 100644 --- a/clickgen/util.pyi +++ b/clickgen/util.pyi @@ -13,6 +13,6 @@ class PNGProvider: def add_missing_xcursors( directory: Path, data: List[Set[str]] = ..., rename: bool = ..., force: bool = ... -) -> bool: ... +) -> None: ... def timer(func: Any): ... def debug(func: Any): ... From 3870684de9d4f6a1989c370ba035f2dffe72326a Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Fri, 5 Mar 2021 17:41:39 +0530 Subject: [PATCH 03/53] =?UTF-8?q?=F0=9F=94=A5=20Linting=20&=20Formatting?= =?UTF-8?q?=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/builders.py | 11 ++++++----- clickgen/builders.pyi | 11 ++++------- clickgen/core.py | 4 ++-- clickgen/core.pyi | 4 ++-- clickgen/db.pyi | 4 +--- clickgen/packagers.py | 44 +++++++++++++++++++++--------------------- clickgen/packagers.pyi | 12 +++--------- clickgen/util.pyi | 8 +++----- tests/test_builders.py | 7 ++++--- 9 files changed, 47 insertions(+), 58 deletions(-) diff --git a/clickgen/builders.py b/clickgen/builders.py index cea06d1b..9a59cd4d 100644 --- a/clickgen/builders.py +++ b/clickgen/builders.py @@ -33,7 +33,7 @@ class XCursor: # main function ctypes define _lib_location: Path = Path(clickgen_pkg_root[0]) / "xcursorgen.so" - _lib: CDLL = CDLL(_lib_location) + _lib: CDLL = CDLL(str(_lib_location.absolute())) _LP_c_char = ctypes.POINTER(ctypes.c_char) _LP_LP_c_char = ctypes.POINTER(_LP_c_char) _lib.main.argtypes = (ctypes.c_int, _LP_LP_c_char) @@ -72,9 +72,9 @@ def generate(self) -> None: argv: List[str] = [ "xcursorgen", "-p", # prefix args for xcursorgen (do not remove) - self.prefix.absolute(), # prefix args for xcursorgen (do not remove) - self.config_file.absolute(), # cursor's config/alias file - self.out.absolute(), # xcursor/output path + str(self.prefix.absolute()), # prefix args for xcursorgen (do not remove) + str(self.config_file.absolute()), # cursor's config/alias file + str(self.out.absolute()), # xcursor/output path ] kwargs: ctypes.pointer[ctypes.c_char] = self.gen_argv_ctypes(argv) @@ -196,7 +196,8 @@ def make_framesets(frames: Frames) -> Frames: sizes = set() # This assumes that frames are sorted - size = counter = 0 + size: int = 0 + counter: int = 0 for i, frame in enumerate(frames): if size == 0 or frame[0] != size: diff --git a/clickgen/builders.pyi b/clickgen/builders.pyi index b6e31439..42c1a3ef 100644 --- a/clickgen/builders.pyi +++ b/clickgen/builders.pyi @@ -1,9 +1,8 @@ import io +from PIL import Image from pathlib import Path from typing import Any, List, Literal, NamedTuple, Tuple -from PIL import Image - Frame = Tuple[int, int, int, str, int] Frames = List[Frame] Color = Tuple[int, int, int, int] @@ -32,9 +31,7 @@ class WindowsCursor: prefix: Path out_dir: Path out: Path - def __init__( - self, config_dir: Path, out_dir: Path, args: AnicursorgenArgs - ) -> None: ... + def __init__(self, config_dir: Path, out_dir: Path, args: AnicursorgenArgs) -> None: ... def get_frames(self) -> Frames: ... @staticmethod def frames_have_animation(frames: Frames) -> bool: ... @@ -50,7 +47,7 @@ class WindowsCursor: def write_png(out: io.BufferedWriter, frame_png: Image) -> None: ... @staticmethod def write_cur(out: io.BufferedWriter, frame: Frame, frame_png: Image) -> None: ... - def make_cur(self, frames: Frames, animated: bool = ...) -> io.BytesIO: ... + def make_cur(self, frames: Frames, animated: bool=...) -> io.BytesIO: ... def generate(self) -> None: ... @classmethod - def create(cls: Any, alias_file: Path, out_dir: Path, args: Any = ...) -> Path: ... + def create(cls: Any, alias_file: Path, out_dir: Path, args: Any=...) -> Path: ... diff --git a/clickgen/core.py b/clickgen/core.py index 73589eaa..e9323e9e 100644 --- a/clickgen/core.py +++ b/clickgen/core.py @@ -76,7 +76,7 @@ def __repr__(self) -> str: def __enter__(self) -> "Bitmap": return self - def __exit__(self) -> None: + def __exit__(self, *args) -> None: self.animated = None self.key = None self.size = None @@ -358,7 +358,7 @@ def __repr__(self) -> str: def __enter__(self) -> "CursorAlias": return self - def __exit__(self): + def __exit__(self, *args): self.bitmap.__exit__() self.bitmap = None diff --git a/clickgen/core.pyi b/clickgen/core.pyi index a6dbbf21..7309f93c 100644 --- a/clickgen/core.pyi +++ b/clickgen/core.pyi @@ -20,7 +20,7 @@ class Bitmap: compress: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] = ... def __init__(self, png: Union[LikePath, LikePathList], hotspot: Tuple[int, int]) -> None: ... def __enter__(self) -> Bitmap: ... - def __exit__(self) -> None: ... + def __exit__(self, *args: Any) -> None: ... def resize(self, size: Size, resample: int=..., save: bool=...) -> Optional[Union[Image, List[Image]]]: ... def reproduce(self, size: Size=..., canvas_size: Size=..., position: Positions=..., save: Any=...) -> Optional[Union[Image, List[Image]]]: ... def rename(self, key: str) -> None: ... @@ -34,7 +34,7 @@ class CursorAlias: garbage_dirs: List[Path] = ... def __init__(self, bitmap: Bitmap) -> None: ... def __enter__(self) -> CursorAlias: ... - def __exit__(self) -> None: ... + def __exit__(self, *args: Any) -> None: ... @classmethod def from_bitmap(cls: Any, png: Union[LikePath, LikePathList], hotspot: Tuple[int, int]) -> CursorAlias: ... def create(self, sizes: Union[Size, List[Size]], delay: int=...) -> Path: ... diff --git a/clickgen/db.pyi b/clickgen/db.pyi index 9c5aedb6..c5af6d6e 100644 --- a/clickgen/db.pyi +++ b/clickgen/db.pyi @@ -7,7 +7,5 @@ DATA: Data class CursorDB: data: Dict[str, List[str]] = ... def __init__(self, data: Data) -> None: ... - def search_symlinks( - self, key: str, find_similar: bool = ... - ) -> Optional[List[str]]: ... + def search_symlinks(self, key: str, find_similar: bool=...) -> Optional[List[str]]: ... def rename_file(self, p: Path) -> Optional[Path]: ... diff --git a/clickgen/packagers.py b/clickgen/packagers.py index 09fdb860..f3d98c8b 100644 --- a/clickgen/packagers.py +++ b/clickgen/packagers.py @@ -3,7 +3,7 @@ from pathlib import Path from string import Template -from typing import Dict, Iterator, Optional, Set +from typing import Dict, List, Optional, Set # --- X11 @@ -57,7 +57,7 @@ def XPackager(directory: Path, theme_name: str, comment: str) -> None: "$Link" "$Move" "$Diagonal_2" -"$Vertical" +"$Vertical" "$Horizontal" "$Diagonal_1" "$Handwriting" @@ -67,27 +67,27 @@ def XPackager(directory: Path, theme_name: str, comment: str) -> None: "$Alternate" [Strings] -CUR_DIR = "Cursors\\$theme_name Cursors" -SCHEME_NAME = "$theme_name Cursors" -pointer = "$Default" -help = "$Help" -work = "$Work" -busy = "$Busy" -cross = "$Cross" -text = "$IBeam" -hand = "$Handwriting" -unavailiable = "$Unavailiable" -vert = "$Vertical" -horz = "$Horizontal" -dgn1 = "$Diagonal_1" -dgn2 = "$Diagonal_2" -move = "$Move" -alternate = "$Alternate" -link = "$Link" +CUR_DIR = "Cursors\\$theme_name Cursors" +SCHEME_NAME = "$theme_name Cursors" +pointer = "$Default" +help = "$Help" +work = "$Work" +busy = "$Busy" +cross = "$Cross" +text = "$IBeam" +hand = "$Handwriting" +unavailiable = "$Unavailiable" +vert = "$Vertical" +horz = "$Horizontal" +dgn1 = "$Diagonal_1" +dgn2 = "$Diagonal_2" +move = "$Move" +alternate = "$Alternate" +link = "$Link" """ ) -REQUIRED_WIN_CURSORS: Iterator[str] = { +REQUIRED_WIN_CURSORS: Set[str] = { "Work", "Busy", "Default", @@ -115,7 +115,7 @@ def WindowsPackager( ) -> None: """ Create a crispy `Windows` cursor theme package. """ - files: Iterator[Path] = [] + files: List[Path] = [] for extensions in ("*.ani", "*.cur"): for i in sorted(directory.glob(extensions)): @@ -137,7 +137,7 @@ def WindowsPackager( raise FileNotFoundError(f"Windows cursors are missing {missing}") if website_url: - comment: str = f"{comment}\n{website_url}" + comment = f"{comment}\n{website_url}" # Real magic of python # replace $Default => Default.ani | Default.cur (as file was provided) diff --git a/clickgen/packagers.pyi b/clickgen/packagers.pyi index 3cab25c7..314957bc 100644 --- a/clickgen/packagers.pyi +++ b/clickgen/packagers.pyi @@ -1,18 +1,12 @@ from pathlib import Path from string import Template -from typing import Any, Dict, Iterator, Optional +from typing import Any, Dict, Optional, Set THEME_FILES_TEMPLATES: Dict[str, Template] def XPackager(directory: Path, theme_name: str, comment: str) -> None: ... INSTALL_INF: Any -REQUIRED_WIN_CURSORS: Iterator[str] +REQUIRED_WIN_CURSORS: Set[str] -def WindowsPackager( - directory: Path, - theme_name: str, - comment: str, - author: str, - website_url: Optional[str] = ..., -) -> None: ... +def WindowsPackager(directory: Path, theme_name: str, comment: str, author: str, website_url: Optional[str]=...) -> None: ... diff --git a/clickgen/util.pyi b/clickgen/util.pyi index a8541788..0ec6b8ab 100644 --- a/clickgen/util.pyi +++ b/clickgen/util.pyi @@ -1,18 +1,16 @@ from pathlib import Path from typing import Any, List, Set, TypeVar, Union -LikePath = TypeVar("LikePath", str, Path) +LikePath = TypeVar('LikePath', str, Path) def chdir(directory: LikePath) -> Any: ... -def remove_util(p: LikePath) -> None: ... +def remove_util(p: Union[str, Path]) -> None: ... class PNGProvider: bitmaps_dir: Path def __init__(self, bitmaps_dir: LikePath) -> None: ... def get(self, key: str) -> Union[List[Path], Path]: ... -def add_missing_xcursors( - directory: Path, data: List[Set[str]] = ..., rename: bool = ..., force: bool = ... -) -> None: ... +def add_missing_xcursors(directory: Path, data: List[Set[str]]=..., rename: bool=..., force: bool=...) -> None: ... def timer(func: Any): ... def debug(func: Any): ... diff --git a/tests/test_builders.py b/tests/test_builders.py index 3019f911..f84e8d30 100644 --- a/tests/test_builders.py +++ b/tests/test_builders.py @@ -1,13 +1,14 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from random import randint -from tests.utils import create_test_image -from build.lib.clickgen.core import CursorAlias from pathlib import Path +from random import randint import pytest + from clickgen.builders import AnicursorgenArgs, WindowsCursor, XCursor +from clickgen.core import CursorAlias +from tests.utils import create_test_image # # XCursor From c50b0370787cd385e3cfac48060a08a6115a8671 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Fri, 5 Mar 2021 17:42:24 +0530 Subject: [PATCH 04/53] =?UTF-8?q?=F0=9F=91=B7=20'make'=20command=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 2fd81bd5..188ee2d5 100644 --- a/setup.py +++ b/setup.py @@ -8,10 +8,17 @@ from setuptools import setup +def make_path() -> str: + path = which("make") + if not path: + raise Exception("'make' command not found") + return path + + class install(_install): def run(self): - subprocess.call([which("make"), "clean", "-C", "xcursorgen"]) - subprocess.call([which("make"), "-C", "xcursorgen"]) + subprocess.call([make_path(), "clean", "-C", "xcursorgen"]) + subprocess.call([make_path(), "-C", "xcursorgen"]) _install.run(self) From dcb73d51f862afdf94e77ee0fc36827849829558 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 6 Mar 2021 12:56:56 +0530 Subject: [PATCH 05/53] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20'LikePath'=20type?= =?UTF-8?q?=20removed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/util.py | 8 +++----- clickgen/util.pyi | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/clickgen/util.py b/clickgen/util.py index 3f632bde..db626ffc 100644 --- a/clickgen/util.py +++ b/clickgen/util.py @@ -8,15 +8,13 @@ import time from contextlib import contextmanager from pathlib import Path -from typing import List, Set, TypeVar, Union +from typing import List, Set, Union from clickgen.db import DATA, CursorDB -LikePath = TypeVar("LikePath", str, Path) - @contextmanager -def chdir(directory: LikePath): +def chdir(directory: Union[str, Path]): """Temporary change `working` directory. :directory: path to directory. @@ -52,7 +50,7 @@ class PNGProvider(object): bitmaps_dir: Path __pngs: List[str] = [] - def __init__(self, bitmaps_dir: LikePath) -> None: + def __init__(self, bitmaps_dir: Union[str, Path]) -> None: """Init `PNGProvider`. :bitmaps_dir: path to directory where `.png` files are stored. diff --git a/clickgen/util.pyi b/clickgen/util.pyi index 0ec6b8ab..ed69156e 100644 --- a/clickgen/util.pyi +++ b/clickgen/util.pyi @@ -1,14 +1,12 @@ from pathlib import Path -from typing import Any, List, Set, TypeVar, Union +from typing import Any, List, Set, Union -LikePath = TypeVar('LikePath', str, Path) - -def chdir(directory: LikePath) -> Any: ... +def chdir(directory: Union[str, Path]) -> Any: ... def remove_util(p: Union[str, Path]) -> None: ... class PNGProvider: bitmaps_dir: Path - def __init__(self, bitmaps_dir: LikePath) -> None: ... + def __init__(self, bitmaps_dir: Union[str, Path]) -> None: ... def get(self, key: str) -> Union[List[Path], Path]: ... def add_missing_xcursors(directory: Path, data: List[Set[str]]=..., rename: bool=..., force: bool=...) -> None: ... From cb440c2ac05094fbfa08757470af27f65a710cce Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 6 Mar 2021 12:57:49 +0530 Subject: [PATCH 06/53] =?UTF-8?q?=E2=9C=A8=20Literal=20typing=20and=20=5F?= =?UTF-8?q?=5Fexit=5F=5F=20updated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bitmap & CursorAlias class member 'None' initialization removed __exit__() parameters added Other Linting fixed --- clickgen/core.py | 39 +++++++++------------------------------ clickgen/core.pyi | 13 ++++++------- 2 files changed, 15 insertions(+), 37 deletions(-) diff --git a/clickgen/core.py b/clickgen/core.py index e9323e9e..d621163d 100644 --- a/clickgen/core.py +++ b/clickgen/core.py @@ -5,16 +5,17 @@ from copy import deepcopy from pathlib import Path from tempfile import mkdtemp -from typing import List, Literal, Optional, Tuple, Union, Dict +from typing import Dict, List, Optional, Tuple, Union from PIL import Image as Img from PIL.Image import Image +from clickgen.util import remove_util + # Typing Size = Tuple[int, int] LikePath = Union[str, Path] LikePathList = Union[List[str], List[Path]] -Positions = Literal["top_left", "top_right", "bottom_right", "bottom_right", "center"] class Bitmap(object): @@ -31,7 +32,7 @@ class Bitmap(object): width: int height: int - compress: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] = 0 + compress: int = 0 def __init__( self, @@ -76,20 +77,8 @@ def __repr__(self) -> str: def __enter__(self) -> "Bitmap": return self - def __exit__(self, *args) -> None: - self.animated = None - self.key = None - self.size = None - self.height = None - self.width = None - self.compress = None - self.x_hot = None - self.y_hot = None - - if hasattr(self, "grouped_png"): - self.grouped_png = None - else: - self.png = None + def __exit__(self, exception_type, exception_value, traceback): # type: ignore + return # # Private methods @@ -240,7 +229,7 @@ def reproduce( self, size: Size = (24, 24), canvas_size: Size = (32, 32), - position: Positions = "center", + position: str = "center", save=True, ) -> Optional[Union[Image, List[Image]]]: def __reproduce(p: Path) -> Image: @@ -358,24 +347,14 @@ def __repr__(self) -> str: def __enter__(self) -> "CursorAlias": return self - def __exit__(self, *args): - self.bitmap.__exit__() - self.bitmap = None - - from clickgen.util import remove_util + def __exit__(self, exception_type, exception_value, traceback): # type: ignore if hasattr(self, "alias_dir"): remove_util(self.alias_dir) - self.alias_dir = None - self.prefix = None - - if hasattr(self, "alias_file"): - self.alias_file = None if hasattr(self, "garbage_dirs"): for p in self.garbage_dirs: remove_util(p) - self.garbage_dirs = None @classmethod def from_bitmap( @@ -518,7 +497,7 @@ def reproduce( self, size: Size = (24, 24), canvas_size: Size = (32, 32), - position: Positions = "center", + position: str = "center", delay: int = 3, ) -> "CursorAlias": self.check_alias() diff --git a/clickgen/core.pyi b/clickgen/core.pyi index 7309f93c..40761261 100644 --- a/clickgen/core.pyi +++ b/clickgen/core.pyi @@ -1,11 +1,10 @@ from PIL.Image import Image as Image from pathlib import Path -from typing import Any, List, Literal, Optional, Tuple, Union +from typing import Any, List, Optional, Tuple, Union Size = Tuple[int, int] LikePath = Union[str, Path] LikePathList = Union[List[str], List[Path]] -Positions: Any class Bitmap: animated: bool @@ -17,12 +16,12 @@ class Bitmap: size: Tuple[int, int] width: int height: int - compress: Literal[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] = ... + compress: int = ... def __init__(self, png: Union[LikePath, LikePathList], hotspot: Tuple[int, int]) -> None: ... def __enter__(self) -> Bitmap: ... - def __exit__(self, *args: Any) -> None: ... + def __exit__(self, exception_type: Any, exception_value: Any, traceback: Any) -> None: ... def resize(self, size: Size, resample: int=..., save: bool=...) -> Optional[Union[Image, List[Image]]]: ... - def reproduce(self, size: Size=..., canvas_size: Size=..., position: Positions=..., save: Any=...) -> Optional[Union[Image, List[Image]]]: ... + def reproduce(self, size: Size=..., canvas_size: Size=..., position: str=..., save: Any=...) -> Optional[Union[Image, List[Image]]]: ... def rename(self, key: str) -> None: ... def copy(self, path: Optional[LikePath]=...) -> Bitmap: ... @@ -34,7 +33,7 @@ class CursorAlias: garbage_dirs: List[Path] = ... def __init__(self, bitmap: Bitmap) -> None: ... def __enter__(self) -> CursorAlias: ... - def __exit__(self, *args: Any) -> None: ... + def __exit__(self, exception_type: Any, exception_value: Any, traceback: Any) -> None: ... @classmethod def from_bitmap(cls: Any, png: Union[LikePath, LikePathList], hotspot: Tuple[int, int]) -> CursorAlias: ... def create(self, sizes: Union[Size, List[Size]], delay: int=...) -> Path: ... @@ -42,4 +41,4 @@ class CursorAlias: def extension(self, ext: Optional[str]=...) -> LikePath: ... def copy(self, dst: Optional[LikePath]=...) -> CursorAlias: ... def rename(self, key: str) -> Path: ... - def reproduce(self, size: Size=..., canvas_size: Size=..., position: Positions=..., delay: int=...) -> CursorAlias: ... + def reproduce(self, size: Size=..., canvas_size: Size=..., position: str=..., delay: int=...) -> CursorAlias: ... From 101996229fbcbf1ce2ac550f5c039decf04c1ca0 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 6 Mar 2021 13:01:22 +0530 Subject: [PATCH 07/53] =?UTF-8?q?=F0=9F=A7=AA=20Test=20updated=20core.py?= =?UTF-8?q?=20module?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_core.py | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/tests/test_core.py b/tests/test_core.py index a8e204d0..4ff0d668 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -8,9 +8,10 @@ from typing import List, Optional import pytest -from clickgen.core import Bitmap, CursorAlias from PIL import Image +from clickgen.core import Bitmap, CursorAlias + from .utils import create_test_image # @@ -206,15 +207,6 @@ def test_static_Bitmap_context_manager(static_png, hotspot) -> None: assert bmp.x_hot == hotspot[0] assert bmp.y_hot == hotspot[1] - assert bmp.png is None - assert bmp.animated is None - assert bmp.height is None - assert bmp.width is None - assert bmp.compress is None - assert bmp.key is None - assert bmp.x_hot is None - assert bmp.y_hot is None - def test_animated_Bitmap_context_manager(animated_png, hotspot) -> None: with Bitmap(animated_png, hotspot) as bmp: @@ -229,15 +221,6 @@ def test_animated_Bitmap_context_manager(animated_png, hotspot) -> None: assert bmp.x_hot == hotspot[0] assert bmp.y_hot == hotspot[1] - assert bmp.grouped_png is None - assert bmp.animated is None - assert bmp.height is None - assert bmp.width is None - assert bmp.compress is None - assert bmp.key is None - assert bmp.x_hot is None - assert bmp.y_hot is None - def test_Bitmap_png_must_had_equal_width_and_height_exception( image_dir, hotspot @@ -251,8 +234,8 @@ def test_animated_Bitmap_all_png_size_must_be_equal_exception( image_dir, hotspot ) -> None: png = create_test_image(image_dir, 2, size=(2, 2)) - png.append(create_test_image(image_dir, 1, size=(3, 6))) - png.append(create_test_image(image_dir, 1, size=(3, 3))) + png.extend(create_test_image(image_dir, 1, size=(3, 6))) + png.extend(create_test_image(image_dir, 1, size=(3, 3))) with pytest.raises(ValueError): assert Bitmap(png, hotspot) @@ -298,6 +281,8 @@ def test_static_Bitmap_resize_without_save(static_png) -> None: assert return_image is not None assert bmp.x_hot == 10 assert bmp.y_hot == 10 + + assert isinstance(return_image, Image.Image) assert return_image.size == new_size @@ -361,10 +346,13 @@ def test_static_Bitmap_reproduce_without_save(static_png) -> None: size=(10, 10), canvas_size=(10, 10), position="center", save=False ) assert return_value is not None + assert isinstance(return_value, list) is False + assert isinstance(return_value, Image.Image) + assert return_value.size == (10, 10) + assert bmp.size == (20, 20) assert bmp.x_hot == 10 assert bmp.y_hot == 10 - assert return_value.size == (10, 10) def test_animated_Bitmap_reproduce_with_save(animated_png) -> None: @@ -410,7 +398,7 @@ def test_static_Bitmap_rename(static_png: Path, hotspot) -> None: assert bmp.grouped_png -def test_animated_Bitmap_rename(animated_png: Path, hotspot) -> None: +def test_animated_Bitmap_rename(animated_png: List[Path], hotspot) -> None: bmp = Bitmap(animated_png, hotspot) assert bmp.key == "test" assert bmp.grouped_png == animated_png @@ -566,10 +554,6 @@ def test_CursorAlias_from_bitmap(static_png, hotspot) -> None: directory = ca.alias_dir assert directory.exists() is False or list(directory.iterdir()) == [] - assert ca.bitmap is None - assert ca.alias_dir is None - assert ca.prefix is None - assert ca.garbage_dirs is None with CursorAlias.from_bitmap(static_png, hotspot) as ca1: with pytest.raises(AttributeError) as excinfo: @@ -580,8 +564,6 @@ def test_CursorAlias_from_bitmap(static_png, hotspot) -> None: ca1.create((10, 10)) assert ca1.alias_file is not None - assert ca1.alias_file is None - def test_static_CursorAlias_str(static_bitmap): alias = CursorAlias(static_bitmap) @@ -1017,7 +999,6 @@ def test_CursorAlias_reproduce(static_png, hotspot) -> None: assert f"{alias.prefix}__garbage_bmps__" in alias.garbage_dirs[0].name assert file_tree(reproduced_alias) == ["32x32", "test-0.alias", "test-0.png"] - assert alias.garbage_dirs is None assert ( sorted(filter(lambda x: x.is_file is True, testing_dirs[0].glob("*/**"))) == [] ) From 768dff016f9dea4b1ff2b9cf245b039c81ee71eb Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 6 Mar 2021 15:25:30 +0530 Subject: [PATCH 08/53] =?UTF-8?q?=F0=9F=93=9A=20v1.1.8=20link=20and=20Logs?= =?UTF-8?q?=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3c2cffd..9e1ba592 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Couple of **linting** problem fixes +- Bitmap and CursorsAlias memember access outside the context manager +- `make` command error raise in `setup.py` +- Better typing experience + +### Changed + +- `Literal` typing removed from `clickgen.util` & `clickgen.core` +- Fixed #23 packaging issue of `XPackager` +- Fixed #22 Inside `util.PNGProvider` + +## [1.1.8] - 24 jan 2021 (Stable) + +### Added + - Code Coverage ~100% - The new CLI - New `XCursor` & `Windows Cursor` building approach @@ -111,7 +126,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - auto-generated **symlinks** based on input configs - `.tar` archive & `directory` as out **package**. -[unreleased]: https://github.com/ful1e5/clickgen/compare/v1.1.7...main +[unreleased]: https://github.com/ful1e5/clickgen/compare/v1.1.8...main +[1.1.8]: https://github.com/ful1e5/clickgen/compare/v1.1.7...v1.1.8 [1.1.7]: https://github.com/ful1e5/clickgen/compare/1.1.6...v1.1.7 [1.1.6]: https://github.com/ful1e5/clickgen/compare/1.1.5-beta...1.1.6 [1.1.5-beta]: https://github.com/ful1e5/clickgen/compare/1.1.4-alpha...1.1.5-beta From 476c951b6a5f76324ff281641d9dfef4fdb47f8b Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 6 Mar 2021 15:29:25 +0530 Subject: [PATCH 09/53] =?UTF-8?q?=F0=9F=90=8D=20Python=203.6,=203.7=20matr?= =?UTF-8?q?ix=20testing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/app-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/app-ci.yml b/.github/workflows/app-ci.yml index 007c6b30..4e8d2057 100644 --- a/.github/workflows/app-ci.yml +++ b/.github/workflows/app-ci.yml @@ -25,7 +25,7 @@ jobs: - name: Set up Python "3.x" uses: actions/setup-python@v2 with: - python-version: '3.x' + python-version: "3.x" - name: Cache pip dependencies uses: actions/cache@v2 @@ -55,8 +55,8 @@ jobs: needs: Linting runs-on: ubuntu-18.04 strategy: - matrix: - python-version: [3.8, 3.9] + matrix: + python-version: [3.6, 3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 @@ -97,7 +97,7 @@ jobs: python setup.py install python -m pytest -vv continue-on-error: false - + build: needs: [Linting, Linux-Testing] runs-on: ubuntu-18.04 @@ -106,7 +106,7 @@ jobs: - name: Set up Python "3.x" uses: actions/setup-python@v2 with: - python-version: '3.x' + python-version: "3.x" - name: Install build dependencies using 'apt' run: sudo apt install libx11-dev libxcursor-dev libpng-dev From 957e8ba39205f863a2c6539dfc9d631f2dac21b8 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 6 Mar 2021 15:37:23 +0530 Subject: [PATCH 10/53] =?UTF-8?q?=E2=9D=8C=F0=9F=94=A2=20Literal=20typing?= =?UTF-8?q?=20removed=20from=20builder.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/builders.py | 4 ++-- clickgen/builders.pyi | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/clickgen/builders.py b/clickgen/builders.py index 9a59cd4d..212037ac 100644 --- a/clickgen/builders.py +++ b/clickgen/builders.py @@ -8,7 +8,7 @@ from ctypes import CDLL from pathlib import Path from struct import pack -from typing import Any, List, Literal, NamedTuple, Tuple +from typing import Any, List, NamedTuple, Tuple from PIL import Image, ImageFilter @@ -327,7 +327,7 @@ def shadowize(shadow: Image, orig: Image, color: Color) -> None: int(color[3] * (o_px[3] / 255.0)), ) - def create_shadow(self, orig: Image) -> Tuple[Literal[0], Any]: + def create_shadow(self, orig: Image) -> Tuple[int, Any]: blur_px = orig.size[0] / 100.0 * self.args.blur right_px = int(orig.size[0] / 100.0 * self.args.right_shift) down_px = int(orig.size[1] / 100.0 * self.args.down_shift) diff --git a/clickgen/builders.pyi b/clickgen/builders.pyi index 42c1a3ef..b08ebcea 100644 --- a/clickgen/builders.pyi +++ b/clickgen/builders.pyi @@ -1,7 +1,7 @@ import io from PIL import Image from pathlib import Path -from typing import Any, List, Literal, NamedTuple, Tuple +from typing import Any, List, NamedTuple, Tuple Frame = Tuple[int, int, int, str, int] Frames = List[Frame] @@ -42,7 +42,7 @@ class WindowsCursor: def make_ani(self, frames: Frames, out_buffer: io.BufferedWriter) -> None: ... @staticmethod def shadowize(shadow: Image, orig: Image, color: Color) -> None: ... - def create_shadow(self, orig: Image) -> Tuple[Literal[0], Any]: ... + def create_shadow(self, orig: Image) -> Tuple[int, Any]: ... @staticmethod def write_png(out: io.BufferedWriter, frame_png: Image) -> None: ... @staticmethod From afff7c9f9b83813be1cb920c5908306b1ee101f5 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 6 Mar 2021 15:57:05 +0530 Subject: [PATCH 11/53] =?UTF-8?q?=E2=98=A0=20python=203.8=20&=203.9=20matr?= =?UTF-8?q?ix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/app-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/app-ci.yml b/.github/workflows/app-ci.yml index 4e8d2057..82cb4c27 100644 --- a/.github/workflows/app-ci.yml +++ b/.github/workflows/app-ci.yml @@ -56,7 +56,7 @@ jobs: runs-on: ubuntu-18.04 strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 From 44d3541f88173d8e358695d397ae904e26aa5ac0 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 6 Mar 2021 15:59:56 +0530 Subject: [PATCH 12/53] =?UTF-8?q?=E2=A4=B5=20Undo=20matix=20testing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/app-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/app-ci.yml b/.github/workflows/app-ci.yml index 82cb4c27..46d71100 100644 --- a/.github/workflows/app-ci.yml +++ b/.github/workflows/app-ci.yml @@ -56,7 +56,7 @@ jobs: runs-on: ubuntu-18.04 strategy: matrix: - python-version: [3.7, 3.8, 3.9] + python-version: [3.8, 3.9] steps: - uses: actions/checkout@v2 From 1ea77bdcc7c14c8817c60ae8f9e0ecf8d9c0118f Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sun, 7 Mar 2021 11:06:25 +0530 Subject: [PATCH 13/53] =?UTF-8?q?=F0=9F=94=A5=20Tag=20line=20spell=20mista?= =?UTF-8?q?ke=20fixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++--- scripts/clickgen | 2 +- setup.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5741cb66..2666d1b5 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ # Clickgen -The hustle free cursor building toolbox 🧰 +The hassle-free cursor building toolbox 🧰 **clickgen** is _API_ for building **X11** and **Windows** Cursors from `.png` files. clickgen is using `anicursorgen` and `xcursorgen` _under the hood_. @@ -106,7 +106,6 @@ with CursorAlias.from_bitmap(png=["all-scroll-01.png", "all-scroll-02.png"], hot ``` - ### create a static `Windows Cursor` (.cur) ```python @@ -131,4 +130,4 @@ with CursorAlias.from_bitmap(png=["all-scroll-01.png", "all-scroll-02.png"], hot win_cfg = alias.create(sizes=(24, 24)) WindowsCursor.create(alias_file=win_cfg, out_dir=Path(".")) -``` \ No newline at end of file +``` diff --git a/scripts/clickgen b/scripts/clickgen index 697b56fd..5330a5cf 100644 --- a/scripts/clickgen +++ b/scripts/clickgen @@ -11,7 +11,7 @@ from clickgen.core import CursorAlias parser = argparse.ArgumentParser( prog="clickgen", - description="The hustle free cursor building toolbox.", + description="The hassle-free cursor building toolbox", ) # Positional Args. parser.add_argument( diff --git a/setup.py b/setup.py index 188ee2d5..5c8e95f2 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,7 @@ def run(self): version="1.1.8", author="Kaiz Khatri", author_email="kaizmandhu@gmail.com", - description="The hustle free cursor building toolbox 🧰", + description="The hassle-free cursor building toolbox 🧰", long_description=long_description, long_description_content_type="text/markdown", url="https://github.com/ful1e5/clickgen", From 7b88f42b07130f307439a16dba7bc764eb9345a1 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 9 Mar 2021 10:32:16 +0530 Subject: [PATCH 14/53] =?UTF-8?q?=F0=9F=93=9A=20Sphinx=20docs=20init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/Makefile | 20 +++++++ docs/about.md | 27 --------- docs/index.md | 11 ---- docs/installation.md | 129 ----------------------------------------- docs/make.bat | 35 +++++++++++ docs/reference/core.md | 8 --- docs/reference/util.md | 104 --------------------------------- docs/source/conf.py | 55 ++++++++++++++++++ docs/source/index.rst | 20 +++++++ 9 files changed, 130 insertions(+), 279 deletions(-) create mode 100644 docs/Makefile delete mode 100644 docs/about.md delete mode 100644 docs/index.md delete mode 100644 docs/installation.md create mode 100644 docs/make.bat delete mode 100644 docs/reference/core.md delete mode 100644 docs/reference/util.md create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 00000000..d0c3cbf1 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/about.md b/docs/about.md deleted file mode 100644 index 9959c612..00000000 --- a/docs/about.md +++ /dev/null @@ -1,27 +0,0 @@ -# About - -## Goals - -The author’s goal is to build hustle free cursor theme through: - -- Cross-Platform and Standardize cursor build approach without runtime dependencies. -- Continuous integration testing via [GitHub Actions](https://github.com/ful1e5/clickgen/actions) -- Publicized development activity on [GitHub](https://github.com/ful1e5/clickgen) -- Regular releases to the [Python Package Index](https://pypi.org/project/clickgen/) - -## License - -clickgen is [licensed under the open source MIT License](https://github.com/ful1e5/clickgen/blob/main/LICENSE) - -## Why a clickgen? - -xcursorgen and anicursorgen.py both are non-standardized CLI tools for building cursor. It means you need both tools for creating a cross-platform compilable cursor theme. Both tools lacking some key functionality, When you've limited amount of knowledge about cursor/s and it's types. - -**Missing functionality in `xcursorgen` & `anicursorgen.py` :** - -- Require _config file_ to built `XCursor`/`CUR`/`ANI`. (that takes ages for creating manually) -- You've to resize all cursor images individually, As we specified inside the config file. -- `xcursorgen` compiled binaries are hard to find on Cloud Images like **Amazon Linux 2**, Because it's dependents on smaller **runtime libraries**, Like _libpng_ and _libxcursor_. So, We can't generate `XCursor` using web technologies. -- Missing _packaging_ compatibility. -- You've to interact through CLI / Write a script to automate the cursor building process. -- Finding and Calculating `hotspots` for each cursor's size is the next level of pain. (that's why there are a small number of cursor developers on [pling.com](https://www.pling.com/browse/cat/107/order/latest/) 🤫) diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index 6f789bf5..00000000 --- a/docs/index.md +++ /dev/null @@ -1,11 +0,0 @@ -# clickgen - -clickgen is hustle free cursor building toolbox by Kaiz Khatri, Built upon powerful tools `anicursorgen.py` and `xcursorgen`. - -# Overview - -This library adds cursor building capabilities to your Python interpreter. - -*xcursorgen* & *anicursorgen.py* tools are designed to build cursor from *config file* once at a time. They should provide a solid foundation for the general cursor building tool. - -- [Installation](installation.md) \ No newline at end of file diff --git a/docs/installation.md b/docs/installation.md deleted file mode 100644 index db184714..00000000 --- a/docs/installation.md +++ /dev/null @@ -1,129 +0,0 @@ -# Installation - -## Warnings - -!!! warning - clickgen CI & Building is tested on Linux platform only. Check [GitHub Action](https://github.com/ful1e5/clickgen/actions) for more detail. - -## Python Support - -clickgen supports these Python versions. - -| **Python** | **3.9** | **3.8** | **3.7** | **3.6** | **3.5** | **3.4** | **3.3** | **3.2** | **2.7** | **2.6** | **2.5** | **2.4** | -| ------------------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | ------- | -| clickgen 1.1.7 | Yes | Yes | Yes | Yes | | | | | | | | | -| clickgen 1.1.6 | Yes | Yes | Yes | Yes | | | | | | | | | -| clickgen 1.1.5beta | Yes | Yes | Yes | Yes | | | | | | | | | -| clickgen 1.1.4beta | Yes | Yes | Yes | Yes | | | | | | | | | -| clickgen 1.1.3alpha | Yes | Yes | Yes | Yes | | | | | | | | | -| clickgen 1.1.2alpha | Yes | Yes | Yes | Yes | | | | | | | | | -| clickgen 1.1.1alpha | Yes | Yes | Yes | Yes | | | | | | | | | -| clickgen 1.1.0alpha | Yes | Yes | Yes | Yes | | | | | | | | | - -## Basic Installation - -!!! warning - The following instructions will install clickgen library only. See [External Libraries](#external-libraries) for a full list of external libraries required by clickgen. - -Install clickgen with **pip**: - -```bash -python3 -m pip install --upgrade pip -python3 -m pip install --upgrade clickgen -``` - -## Building From Source - -Download and extract the [compressed archive from PyPI](https://pypi.org/project/clickgen/). - -### External Libraries - -!!! note - clickgen is using xcursorgen CLI internally for making xcursors. - -xcursorgen require external libraries: - -- **libpng** provides PNG functionality. - - Starting with clickgen 1.1.0, libpng is required by default. -- **zlib** provides access to compressed PNGs. - - Starting with clickgen 1.1.0, zlib is required by default. -- **libXcursor** X Window System Cursor management library. - - Starting with clickgen 1.1.0, libXcursor is required by default. -- **libX11** Core X11 protocol client library. - - Starting with clickgen 1.1.0, libX11 is required by default. - -### Building on macOS - -The easiest way to install external libraries is via [Homebrew](https://brew.sh/). After you install Homebrew, run: - -```bash -brew install gcc libpng -brew install --cask xquartz -``` - -Now install clickgen with: - -```bash -python3 -m pip install --upgrade pip -python3 -m pip install --upgrade clickgen -``` - -or from within the uncompressed source directory: - -```bash -python3 setup.py install -``` - -### Building on Linux - -If you didn’t build Python from source, make sure you have Python’s development libraries installed. - -In Debian or Ubuntu: - -```bash -sudo apt-get install python3-dev python3-setuptools -``` - -In Fedora, the command is: - -```bash -sudo dnf install python3-devel redhat-rpm-config -``` -!!! note - `redhat-rpm-config` is required on Fedora 23, but not earlier versions. - -Prerequisites for **Ubuntu 16.04 LTS - 20.04 LTS** are installed with: - -```bash -sudo apt install libx11-dev libxcursor-dev libpng-dev -``` - -Prerequisites are installed on **Arch Linux, Manjaro** with: - -```bash -sudo pacman -S libx11 libxcursor libpng -``` - -Prerequisites are installed on recent **Red Hat, CentOS** or **Fedora** with: - -```bash -sudo dnf install libx11-devel libxcursor-devel libpng-devel -``` - -Note that the package manager may be yum or DNF, depending on the exact distribution. - -## Platform Support - -Current platform support for clickgen. Binary distributions are contributed for each release on a volunteer basis, but the source should compile and run everywhere platform support is listed. In general, we aim to support all current versions of Linux and macOS. - -### Continuous Integration Targets - -These platforms are built and tested for every change. - -| Operating system | Tested Python versions | Tested architecture | -| ------------------------------- | ---------------------- | ------------------- | -| Ubuntu Linux 18.04 LTS (Bionic) | 3.8, 3.9 | x86-64 | - -## Old Versions - -You can download old distributions from the [release history at PyPI](https://pypi.org/project/clickgen/#history) and by direct URL access eg. [https://pypi.org/project/clickgen/1.1.0/](https://pypi.org/project/clickgen/1.1.0/). diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 00000000..6247f7e2 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/reference/core.md b/docs/reference/core.md deleted file mode 100644 index 64516074..00000000 --- a/docs/reference/core.md +++ /dev/null @@ -1,8 +0,0 @@ -# `core` Module -TODO: INFO - -## Classes - -::: clickgen.core.Bitmap - -::: clickgen.core.CursorAlias diff --git a/docs/reference/util.md b/docs/reference/util.md deleted file mode 100644 index 86ad9a41..00000000 --- a/docs/reference/util.md +++ /dev/null @@ -1,104 +0,0 @@ -# `clickgen.util` Module - -This module provides utility functions and classes, Which makes developer life easier. - - - -## `clickgen.util.LikePath` - -Provide location `typing`. - - - -## `clickgen.util.chdir` - -Temporary change `working` directory. - -!!! Note - Use inside `with` syntax. - -### Args - -directory ([`LikePath`](#likepath)): path to directory. - -### Returns - -`None`. - -### Example - -```python ->>> with clickgen.util.chdir("new"): ->>> print(os.cwd()) ->>> print(os.cwd()) - -/tmp/new/ -/tmp/ -``` - - - -## `clickgen.util.remove_util` - -Remove this file, directory or symlink. If Path exits on filesystem. - -!!! Warning - Some times `remove_util` leaves directory fingerprints (An empty directory). - -### Args - -p ([`LikePath`](#likepath)): path to directory. - -### Returns - -`None`. - -### Examples - -```python ->>> remove_util("/tmp/new") ->>> remove_util(Path("/tmp/new")) -``` - - - -## `clickgen.util.PNGProvider` - -Provide organized `.png` files. - -### Attributes - -bitmaps_dir (`pathlib.Path`): Hold `.png` files directory passed in `__init__`. - -### `PNGProvider.__init__()` - -#### Args - -bitmaps_dir ([`LikePath`](#likepath)): path to directory where `.png` files are stored. - -#### Returns - -`None`. - -#### Raises - -- `FileNotFoundError`: If zero `.png` file found provided directory. - -### `PNGProvider.get()` - -Get `.png` file/s from key. -This method return file location in `pathlib.Path` instance. - -Also, this method is not supported directory sync, Which means creating a new file or deleting a file not affect this method. - -The only way to sync the directory is, By creating a new instance of the `PNGProvider` class. - -#### Args - -key (str): `.png` filename without extension. - -#### Returns - -- `pathlib.Path`: Only one .png file found in provided directory. - -- `List[pathlib.Path]`: Multiple `.png` files are found in provided directory. diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 00000000..e82fa6b7 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,55 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + + +# -- Project information ----------------------------------------------------- + +project = 'clickgen' +copyright = '2021, Kaiz Khatri' +author = 'Kaiz Khatri' + +# The full version, including alpha/beta/rc tags +release = '1.2.0' + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'alabaster' + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 00000000..5074b301 --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,20 @@ +.. clickgen documentation master file, created by + sphinx-quickstart on Tue Mar 9 10:31:08 2021. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to clickgen's documentation! +==================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` From 1caef4c0cc7c7ece8eb3d8b802cd97b5a9d9c8a2 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 9 Mar 2021 12:15:03 +0530 Subject: [PATCH 15/53] =?UTF-8?q?=F0=9F=93=9D=20Autodoc=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/clickgen.rst | 53 ++++++++++++++++++++++++++++++++++++++++ docs/source/conf.py | 24 +++++++++--------- docs/source/index.rst | 4 +-- docs/source/modules.rst | 8 ++++++ 4 files changed, 75 insertions(+), 14 deletions(-) create mode 100644 docs/source/clickgen.rst create mode 100644 docs/source/modules.rst diff --git a/docs/source/clickgen.rst b/docs/source/clickgen.rst new file mode 100644 index 00000000..cd9965bc --- /dev/null +++ b/docs/source/clickgen.rst @@ -0,0 +1,53 @@ +clickgen package +================ + +Submodules +---------- + +clickgen.builders module +------------------------ + +.. automodule:: clickgen.builders + :members: + :undoc-members: + :show-inheritance: + +clickgen.core module +-------------------- + +.. automodule:: clickgen.core + :members: + :undoc-members: + :show-inheritance: + +clickgen.db module +------------------ + +.. automodule:: clickgen.db + :members: + :undoc-members: + :show-inheritance: + +clickgen.packagers module +------------------------- + +.. automodule:: clickgen.packagers + :members: + :undoc-members: + :show-inheritance: + +clickgen.util module +-------------------- + +.. automodule:: clickgen.util + :members: + :undoc-members: + :show-inheritance: + +Module contents +--------------- + +.. automodule:: clickgen + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/conf.py b/docs/source/conf.py index e82fa6b7..ec6443cc 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -10,19 +10,20 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) +import os +import sys + +sys.path.insert(0, os.path.abspath("../../clickgen")) # -- Project information ----------------------------------------------------- -project = 'clickgen' -copyright = '2021, Kaiz Khatri' -author = 'Kaiz Khatri' +project = "clickgen" +copyright = "2021, Kaiz Khatri" +author = "Kaiz Khatri" # The full version, including alpha/beta/rc tags -release = '1.2.0' +release = "1.2.0" # -- General configuration --------------------------------------------------- @@ -30,11 +31,10 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = [ -] +extensions = ["sphinx.ext.todo", "sphinx.ext.viewcode", "sphinx.ext.autodoc"] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -47,9 +47,9 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'alabaster' +html_theme = "sphinx_rtd_theme" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] \ No newline at end of file +html_static_path = ["_static"] diff --git a/docs/source/index.rst b/docs/source/index.rst index 5074b301..0791dbb2 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -3,8 +3,8 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. -Welcome to clickgen's documentation! -==================================== +clickgen +======== .. toctree:: :maxdepth: 2 diff --git a/docs/source/modules.rst b/docs/source/modules.rst new file mode 100644 index 00000000..cfd7ab1b --- /dev/null +++ b/docs/source/modules.rst @@ -0,0 +1,8 @@ + +Clickgen Modules +================ + +.. toctree:: + :maxdepth: 4 + + clickgen From ce2b1908a58ead7de258d141b98f034f1091cf3e Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 9 Mar 2021 12:15:36 +0530 Subject: [PATCH 16/53] =?UTF-8?q?=F0=9F=93=A6=20reST=20docs=20strings=20ad?= =?UTF-8?q?ded?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/util.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/clickgen/util.py b/clickgen/util.py index db626ffc..bd8c4cdb 100644 --- a/clickgen/util.py +++ b/clickgen/util.py @@ -15,9 +15,11 @@ @contextmanager def chdir(directory: Union[str, Path]): - """Temporary change `working` directory. + """Temporary change working directory using `with` syntax. + + :param directory: path to directory. + :type directory: Union[str, pathlib.Path] - :directory: path to directory. """ prev_cwd = os.getcwd() @@ -29,9 +31,13 @@ def chdir(directory: Union[str, Path]): def remove_util(p: Union[str, Path]) -> None: - """Remove this file, directory or symlink. If Path exits on filesystem. + """Remove this file, directory or symlink. + + :param p: path to directory. + :type p: Union[str, pathlib.Path] + :return: None + :rtype: None - :p: path to directory. """ p_obj: Path = Path(p) @@ -53,7 +59,9 @@ class PNGProvider(object): def __init__(self, bitmaps_dir: Union[str, Path]) -> None: """Init `PNGProvider`. - :bitmaps_dir: path to directory where `.png` files are stored. + :param bitmaps_dir: Path to directory where `.png` files are stored. + :type bitmaps_dir: Union[str, Path] + """ super().__init__() self.bitmaps_dir = Path(bitmaps_dir) @@ -66,15 +74,20 @@ def __init__(self, bitmaps_dir: Union[str, Path]) -> None: ) def get(self, key: str) -> Union[List[Path], Path]: - """Get `.png` file/s from key. - This method return file location in `pathlib.Path` instance. + """Retrieve `pathlib.Path` of filtered `.png` file/s. - Also, this method is not supported directory sync, Which means creating a new file or deleting a file not affect this method. + This method return file location in `pathlib.Path` object. - The only way to sync the directory is, By creating a new instance of the `PNGProvider` class. + Runtime directory `sync` is **not supported**, Which means creating + or deleting a file on programs execution is not update class `__pngs` + state. - :key: Without extension it search for multiple files, Else search the key with `.png` extension. + :param key: `key` is filename + :type key: str + :return: Returns `pathlib.Path` object or `list` of `pathlib.Path` + object/s. """ + k = key.split(".") if len(k) == 1: r = re.compile(fr"^{k[0]}(?:-\d+)?.png$") From 9de2447a9c9182bea24fad028aa7d3aa092a9442 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 9 Mar 2021 12:20:19 +0530 Subject: [PATCH 17/53] =?UTF-8?q?=F0=9F=93=A6=20ReadTheDocs=20requirements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/requirements.txt | 3 +++ mkdocs.yml | 31 ------------------------------- readthedocs.yml | 21 ++++++++++++++++++--- 3 files changed, 21 insertions(+), 34 deletions(-) create mode 100644 docs/requirements.txt delete mode 100644 mkdocs.yml diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 00000000..707e9f5e --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,3 @@ +Pillow +sphinx-rtd-theme + diff --git a/mkdocs.yml b/mkdocs.yml deleted file mode 100644 index e650f961..00000000 --- a/mkdocs.yml +++ /dev/null @@ -1,31 +0,0 @@ -site_name: clickgen -site_description: X11 & Windows cursor building toolbox 🧰 -site_author: Kaiz Khatri - -repo_url: https://github.com/ful1e5/clickgen - -theme: - name: readthedocs - highlightjs: true - hljs_languages: - - shell - - python - -nav: - - Installation: installation.md - - About: about.md - - Reference: - - reference/core.md - - reference/util.md - - "Bug Tracker": https://github.com/ful1e5/clickgen/issues - -markdown_extensions: - - toc: - permalink:  - - admonition - - def_list - -copyright: '© copyright 2021, Kaiz Khatri & Contributors' - -plugins: - - search diff --git a/readthedocs.yml b/readthedocs.yml index 9a58a64c..fd303691 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -1,5 +1,20 @@ +# .readthedocs.yaml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required version: 2 -# Build documentation with MkDocs -mkdocs: - configuration: mkdocs.yml +# Build documentation in the docs/ directory with Sphinx +sphinx: + configuration: docs/source/conf.py + +# Optionally build your docs in additional formats such as PDF +formats: + - pdf + +# Optionally set the version of Python and requirements required to build your docs +python: + version: 3.7 + install: + - requirements: docs/requirements.txt From 99a31a88ab89dfc93cdcdad430e9a05eefeb0f78 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 9 Mar 2021 17:13:34 +0530 Subject: [PATCH 18/53] =?UTF-8?q?=E2=9A=A1=F0=9F=92=BE=20Installations=20d?= =?UTF-8?q?ocs=20init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/installation.rst | 156 +++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 docs/source/installation.rst diff --git a/docs/source/installation.rst b/docs/source/installation.rst new file mode 100644 index 00000000..0476c017 --- /dev/null +++ b/docs/source/installation.rst @@ -0,0 +1,156 @@ + +Installation +============ + +Warnings +-------- + +.. warning:: + clickgen CI & Building is tested on Linux platform only. + Check `GitHub Action `_ for + more detail. + + +Python Support +-------------- +clickgen supports these Python versions. + ++---------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ +| **Python** | **3.9** | **3.8** | **3.7** | **3.6** | **3.5** | **3.4** | **3.3** | **3.2** | **2.7** | **2.6** | **2.5** | **2.4** | ++=====================+=========+=========+=========+=========+=========+=========+=========+=========+=========+=========+=========+=========+ +| clickgen 1.1.8 | Yes | Yes | | | | | | | | | | | ++---------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ +| clickgen 1.1.7 | Yes | Yes | Yes | Yes | | | | | | | | | ++---------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ +| clickgen 1.1.6 | Yes | Yes | Yes | Yes | | | | | | | | | ++---------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ +| clickgen 1.1.5beta | Yes | Yes | Yes | Yes | | | | | | | | | ++---------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ +| clickgen 1.1.4beta | Yes | Yes | Yes | Yes | | | | | | | | | ++---------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ +| clickgen 1.1.3alpha | Yes | Yes | Yes | Yes | | | | | | | | | ++---------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ +| clickgen 1.1.2alpha | Yes | Yes | Yes | Yes | | | | | | | | | ++---------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ +| clickgen 1.1.1alpha | Yes | Yes | Yes | Yes | | | | | | | | | ++---------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ +| clickgen 1.1.0alpha | Yes | Yes | Yes | Yes | | | | | | | | | ++---------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ + + +Basic Installation +------------------ +.. note:: + + The following instructions will install clickgen with support for + most common image formats. See :ref:`external-libraries` for a + full list of external libraries supported. + +Install clickgen with :command:`pip`:: + + python3 -m pip install --upgrade pip + python3 -m pip install --upgrade clickgen + + + +Building From Source +-------------------- +Download and extract the `compressed archive from PyPI`_. + +.. _compressed archive from PyPI: https://pypi.org/project/clickgen/ + +.. _external-libraries: + +External Libraries +^^^^^^^^^^^^^^^^^^ +.. note:: + clickgen is using ``xcursorgen`` CLI internally for making xcursors. + +xcursorgen require external libraries: + +* **libpng** provides PNG functionality. + * Starting with clickgen 1.1.0, libpng is required by default. + +* **zlib** provides access to compressed PNGs. + * Starting with clickgen 1.1.0, zlib is required by default. + +* **libXcursor** X Window System Cursor management library. + * Starting with clickgen 1.1.0, libXcursor is required by default. + +* **libX11** Core X11 protocol client library. + * Starting with clickgen 1.1.0, libX11 is required by default. + + +Once you have installed the prerequisites, run:: + + python3 -m pip install --upgrade pip + python3 -m pip install --upgrade clickgen + +Building on macOS +^^^^^^^^^^^^^^^^^ +The easiest way to install external libraries is via `Homebrew +`_. After you install Homebrew, run:: + + brew install gcc libpng + brew install --cask xquartz + +Now install clickgen with:: + + python3 -m pip install --upgrade pip + python3 -m pip install --upgrade clickgen + +or from within the uncompressed source directory:: + + python3 setup.py install + +Building on Linux +^^^^^^^^^^^^^^^^^ +If you didn’t build Python from source, make sure you have Python’s development +libraries installed. + +In Debian or Ubuntu:: + + sudo apt-get install python3-dev python3-setuptools + +In Fedora, the command is:: + + sudo dnf install python3-devel redhat-rpm-config + +.. Note:: ``redhat-rpm-config`` is required on Fedora 23, but not earlier versions. + +Prerequisites for **Ubuntu 16.04 LTS - 20.04 LTS** are installed with:: + + sudo apt install libx11-dev libxcursor-dev libpng-dev + +Prerequisites are installed on **Arch Linux, Manjaro** with:: + + sudo pacman -S libx11 libxcursor libpng + +Prerequisites are installed on recent **Red Hat, CentOS** or **Fedora** with:: + + sudo dnf install libx11-devel libxcursor-devel libpng-devel + +Note that the package manager may be yum or DNF, depending on the exact distribution. + +Platform Support +^^^^^^^^^^^^^^^^ +Current platform support for clickgen. Binary distributions are contributed for each +release on a volunteer basis, but the source should compile and run everywhere platform +support is listed. In general, we aim to support all current versions of Linux and macOS. + +Continuous Integration Targets +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +These platforms are built and tested for every change. + ++---------------------------------+----------------------------+-------------------------+ +| **Operating system** | **Tested Python versions** | **Tested architecture** | ++---------------------------------+----------------------------+-------------------------+ +| Ubuntu Linux 18.04 LTS (Bionic) | 3.8, 3.9 | x86-64 | ++---------------------------------+----------------------------+-------------------------+ + +.. _release history at PyPI: https://pypi.org/project/clickgen/#history + +Old Versions +^^^^^^^^^^^^ +You can download old distributions from the `release history at PyPI`_ and by direct URL access +eg. https://pypi.org/project/clickgen/1.1.0/. From cc103972183b6d67594aa33ad78e82c78e98afed Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 9 Mar 2021 17:14:25 +0530 Subject: [PATCH 19/53] =?UTF-8?q?=F0=9F=9A=80=20Theme=20&=20other=20config?= =?UTF-8?q?=20(docs)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/conf.py | 4 ++++ docs/source/index.rst | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index ec6443cc..77b05819 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -53,3 +53,7 @@ # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] + + +# GitHub repo for sphinx-issues +issues_github_path = "ful1e5/clickgen" diff --git a/docs/source/index.rst b/docs/source/index.rst index 0791dbb2..f5a39131 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -6,10 +6,23 @@ clickgen ======== +clickgen is hussle free cursor building toolbox by `Kaiz Khatri`, Built upon powerful tools +`anicursorgen.py `_ +and `xcursorgen `_. + + +Overview +======== + +This library adds cursor building capabilities to your Python interpreter. + +``xcursorgen`` & ``anicursorgen.py`` tools are designed to build cursor from *config file* once at +a time. They should provide a solid foundation for the general cursor building tool. + .. toctree:: - :maxdepth: 2 - :caption: Contents: + :maxdepth: 4 + installation.rst Indices and tables From 35bad6c5a38b9baa9863507d2edb558fa415523d Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Wed, 10 Mar 2021 16:31:06 +0530 Subject: [PATCH 20/53] =?UTF-8?q?=F0=9F=94=A5=20Badges=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/conf.py | 6 +++++- docs/source/index.rst | 20 ++++++++++++++++++++ docs/source/installation.rst | 6 ++++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 77b05819..3c32ee43 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -31,7 +31,11 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ["sphinx.ext.todo", "sphinx.ext.viewcode", "sphinx.ext.autodoc"] +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", + "sphinx.ext.viewcode", +] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] diff --git a/docs/source/index.rst b/docs/source/index.rst index f5a39131..5fc524d2 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -10,6 +10,25 @@ clickgen is hussle free cursor building toolbox by `Kaiz Khatri`, Built upon pow `anicursorgen.py `_ and `xcursorgen `_. +.. image:: https://readthedocs.org/projects/clickgen/badge/?version=latest + :target: https://clickgen.readthedocs.io/en/latest/?badge=latest + :alt: Documentation Status + +.. image:: https://github.com/ful1e5/clickgen/actions/workflows/app-ci.yml/badge.svg + :target: https://github.com/ful1e5/clickgen/actions + :alt: GitHub Actions build status + +.. image:: https://img.shields.io/pypi/wheel/pytype + :target: https://pypi.org/project/clickgen/#files + :alt: PyPI - Wheel + +.. image:: https://codecov.io/gh/ful1e5/clickgen/branch/main/graph/badge.svg + :target: https://codecov.io/gh/ful1e5/clickgen + :alt: Code Coverage + +.. image:: https://www.codefactor.io/repository/github/ful1e5/clickgen/badge/main + :target: https://www.codefactor.io/repository/github/ful1e5/clickgen/overview/main + :alt: CodeFactor Overview ======== @@ -23,6 +42,7 @@ a time. They should provide a solid foundation for the general cursor building t :maxdepth: 4 installation.rst + modules.rst Indices and tables diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 0476c017..6d48db23 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -132,8 +132,9 @@ Prerequisites are installed on recent **Red Hat, CentOS** or **Fedora** with:: Note that the package manager may be yum or DNF, depending on the exact distribution. + Platform Support -^^^^^^^^^^^^^^^^ +---------------- Current platform support for clickgen. Binary distributions are contributed for each release on a volunteer basis, but the source should compile and run everywhere platform support is listed. In general, we aim to support all current versions of Linux and macOS. @@ -148,9 +149,10 @@ These platforms are built and tested for every change. | Ubuntu Linux 18.04 LTS (Bionic) | 3.8, 3.9 | x86-64 | +---------------------------------+----------------------------+-------------------------+ + .. _release history at PyPI: https://pypi.org/project/clickgen/#history Old Versions -^^^^^^^^^^^^ +------------ You can download old distributions from the `release history at PyPI`_ and by direct URL access eg. https://pypi.org/project/clickgen/1.1.0/. From 6dc98009e45ea295c93aae6d5771fcbb69bf9b66 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Wed, 10 Mar 2021 16:49:21 +0530 Subject: [PATCH 21/53] =?UTF-8?q?=E2=84=B9=EF=B8=8F=20=20About=20page=20in?= =?UTF-8?q?it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/about.rst | 38 ++++++++++++++++++++++++++++++++++++++ docs/source/index.rst | 3 ++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 docs/source/about.rst diff --git a/docs/source/about.rst b/docs/source/about.rst new file mode 100644 index 00000000..091448d0 --- /dev/null +++ b/docs/source/about.rst @@ -0,0 +1,38 @@ + +About +===== + +Goals +----- +The author’s goal is to build hustle free cursor theme through: + +- Cross-Platform and Standardize cursor build approach without runtime + dependencies. +- Continuous integration testing via `GitHub Actions `_ +- Publicized development activity on `GitHub `_ +- Regular releases to the `Python Package Index `_ + +License +------- +clickgen is `licensed under the open source MIT License `_ + + +Why a clickgen? +--------------- +``xcursorgen`` and ``anicursorgen.py`` both are non-standardized CLI tools for +building cursor. It means you need both tools for creating a cross-platform compilable +cursor theme. Both tools lacking some key functionality, When you've limited amount of +knowledge about cursor/s and it's types. + +Missing functionality in ``xcursorgen`` & ``anicursorgen.py`` : +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + * Require *config file* to built ``XCursor``/``CUR``/``ANI``. (that takes ages for creating manually) + * You've to resize all cursor images individually, As we specified inside the config file. + * ``xcursorgen`` compiled binaries are hard to find on Cloud Images like **Amazon Linux 2**, + Because it's dependents on smaller **runtime libraries**, Like *libpng* and *libxcursor*. + So, We can't generate ``XCursor`` using web technologies. + * Missing *packaging* compatibility. + * You've to interact through CLI / Write a script to automate the cursor building process. + * Finding and Calculating ``hotspots`` for each cursor's size is the next level of pain. + (that's why there are a small number of cursor developers on `pling.com `_ 🤫) + diff --git a/docs/source/index.rst b/docs/source/index.rst index 5fc524d2..476570f2 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -39,10 +39,11 @@ This library adds cursor building capabilities to your Python interpreter. a time. They should provide a solid foundation for the general cursor building tool. .. toctree:: - :maxdepth: 4 + :maxdepth: 2 installation.rst modules.rst + about.rst Indices and tables From 28f02171cc47f50502f51640114fa021788840e7 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Wed, 10 Mar 2021 17:45:46 +0530 Subject: [PATCH 22/53] =?UTF-8?q?=E2=9A=A1=20clickgen.util=20docs=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/clickgen.rst | 53 --------------------------------- docs/source/index.rst | 2 +- docs/source/modules.rst | 8 ----- docs/source/reference/index.rst | 6 ++++ docs/source/reference/util.rst | 31 +++++++++++++++++++ 5 files changed, 38 insertions(+), 62 deletions(-) delete mode 100644 docs/source/clickgen.rst delete mode 100644 docs/source/modules.rst create mode 100644 docs/source/reference/index.rst create mode 100644 docs/source/reference/util.rst diff --git a/docs/source/clickgen.rst b/docs/source/clickgen.rst deleted file mode 100644 index cd9965bc..00000000 --- a/docs/source/clickgen.rst +++ /dev/null @@ -1,53 +0,0 @@ -clickgen package -================ - -Submodules ----------- - -clickgen.builders module ------------------------- - -.. automodule:: clickgen.builders - :members: - :undoc-members: - :show-inheritance: - -clickgen.core module --------------------- - -.. automodule:: clickgen.core - :members: - :undoc-members: - :show-inheritance: - -clickgen.db module ------------------- - -.. automodule:: clickgen.db - :members: - :undoc-members: - :show-inheritance: - -clickgen.packagers module -------------------------- - -.. automodule:: clickgen.packagers - :members: - :undoc-members: - :show-inheritance: - -clickgen.util module --------------------- - -.. automodule:: clickgen.util - :members: - :undoc-members: - :show-inheritance: - -Module contents ---------------- - -.. automodule:: clickgen - :members: - :undoc-members: - :show-inheritance: diff --git a/docs/source/index.rst b/docs/source/index.rst index 476570f2..32f8564f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -42,7 +42,7 @@ a time. They should provide a solid foundation for the general cursor building t :maxdepth: 2 installation.rst - modules.rst + reference/index.rst about.rst diff --git a/docs/source/modules.rst b/docs/source/modules.rst deleted file mode 100644 index cfd7ab1b..00000000 --- a/docs/source/modules.rst +++ /dev/null @@ -1,8 +0,0 @@ - -Clickgen Modules -================ - -.. toctree:: - :maxdepth: 4 - - clickgen diff --git a/docs/source/reference/index.rst b/docs/source/reference/index.rst new file mode 100644 index 00000000..a4ec8d7a --- /dev/null +++ b/docs/source/reference/index.rst @@ -0,0 +1,6 @@ + +.. toctree:: + :maxdepth: 2 + + + util diff --git a/docs/source/reference/util.rst b/docs/source/reference/util.rst new file mode 100644 index 00000000..6ea51f94 --- /dev/null +++ b/docs/source/reference/util.rst @@ -0,0 +1,31 @@ +.. py:module:: clickgen.util +.. py:currentmodule:: clickgen.util + +:py:mod:`~clickgen.util` Module +=============================== + +This module provides utility functions and classes, Which makes developer life easier. + + +Classes +------- +.. autoclass:: clickgen.util.PNGProvider +.. automethod:: clickgen.util.PNGProvider.get + +Functions +--------- + +Add missing ``Xcursor`` +^^^^^^^^^^^^^^^^^^^^^^^ +.. autofunction:: add_missing_xcursors + +Utility +^^^^^^^ +.. autofunction:: chdir +.. autofunction:: remove_util + +For developer only +^^^^^^^^^^^^^^^^^^ +.. autofunction:: timer +.. autofunction:: debug + From dd2bc12be7924d410b45e4592e790555c4e24b96 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Wed, 10 Mar 2021 17:47:00 +0530 Subject: [PATCH 23/53] =?UTF-8?q?=E2=9A=A1=20about=20section=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/about.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/about.rst b/docs/source/about.rst index 091448d0..12a9d606 100644 --- a/docs/source/about.rst +++ b/docs/source/about.rst @@ -25,7 +25,7 @@ cursor theme. Both tools lacking some key functionality, When you've limited amo knowledge about cursor/s and it's types. Missing functionality in ``xcursorgen`` & ``anicursorgen.py`` : -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * Require *config file* to built ``XCursor``/``CUR``/``ANI``. (that takes ages for creating manually) * You've to resize all cursor images individually, As we specified inside the config file. * ``xcursorgen`` compiled binaries are hard to find on Cloud Images like **Amazon Linux 2**, From 1d67376754a5981b453008d6521752094be137e5 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Thu, 11 Mar 2021 17:34:08 +0530 Subject: [PATCH 24/53] =?UTF-8?q?=E2=9A=A1=20clickgen.db=20docs=20init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/db.py | 45 ++++++++++++++++++++++++++++++++++++++++++--- clickgen/util.py | 3 ++- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/clickgen/db.py b/clickgen/db.py index c9e7b895..3719f72c 100644 --- a/clickgen/db.py +++ b/clickgen/db.py @@ -188,16 +188,32 @@ class CursorDB(object): + """The CursorDB class provides ``Xcursor`` data available on X11/Wayland + /XWayland. + """ + data: Dict[str, List[str]] = {} def __init__(self, data: Data) -> None: + """Initiate CursorDB instance. + + This call ``self.__seed`` for setting dataset into ``Dict`` structure. + + :param data: Provide custom dataset of cursors. default to ``clickgen.db.DATA`` + :type data: List[Set[str]] + + :returns: Instance of ``CursorDB`` + + :raises TypeError: If provided ``data`` is not type of ``List`` + :raises TypeError: If provided ``data``'s list member is not type of ``Set`` + """ super().__init__() self.__seed(data) def __str__(self) -> str: string: List[str] = [] - for k, v in self.data.items(): - string.append(f"{k}={v}") + for index, data in self.data.items(): + string.append(f"{index}={data}") return f"CursorDB({', '.join(string)})" def __repr__(self) -> str: @@ -205,7 +221,7 @@ def __repr__(self) -> str: def __seed(self, data: Data) -> None: if not isinstance(data, list): - raise TypeError(f"'data' is not type of 'List'") + raise TypeError("'data' is not type of 'List'") for item in sorted(data): if not isinstance(item, set): raise TypeError(f"Item '{item}' is not type of 'Set'") @@ -217,6 +233,18 @@ def __seed(self, data: Data) -> None: def search_symlinks( self, key: str, find_similar: bool = False ) -> Optional[List[str]]: + """Retrieve similar implementation Xcursor from database. + + :param key: Name of XCursor + :type key: str + + :param find_similar: If this flag set to ``True``, It return similar named ``XCursor`` from database. + :type find_similar: bool + + :return: List of missing ``XCursor`` in string list or None. + :rtype: Optional[List[str]] + + """ if find_similar: key = self.__find_similar(key) @@ -234,6 +262,17 @@ def __find_similar(self, key: str) -> str: return result def rename_file(self, p: Path) -> Optional[Path]: + """Search similar named Xcursor in database. If name of XCursor is not + correct this return ``pathlib.Path`` Object. + + :param p: Path to XCursor + :type key: Path + + :return: Return renamed ``Path`` If XCursor name not correct. + :rtype: Optional[Path] + + :raise FileNotFoundError: If file is not found in file system or it's a directory. + """ if not p.is_file(): raise FileNotFoundError(f"'{p.absolute()}' is not file") key: str = self.__find_similar(p.stem) diff --git a/clickgen/util.py b/clickgen/util.py index bd8c4cdb..5b0c868d 100644 --- a/clickgen/util.py +++ b/clickgen/util.py @@ -50,7 +50,7 @@ def remove_util(p: Union[str, Path]) -> None: pass -class PNGProvider(object): +class PNGProvider: """Provide organized `.png` files.""" bitmaps_dir: Path @@ -108,6 +108,7 @@ def add_missing_xcursors( rename: bool = False, force: bool = False, ) -> None: + """Create symlinks of missing ``Xcursor``""" if not directory.exists() or not directory.is_dir(): raise NotADirectoryError(directory.absolute()) From 4c8c219ec10fb706504cd3e7260c60ed947be292 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Thu, 11 Mar 2021 17:34:36 +0530 Subject: [PATCH 25/53] =?UTF-8?q?=F0=9F=92=BE=20Docs=20module=20updated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/reference/db.rst | 25 +++++++++++++++++++++++++ docs/source/reference/index.rst | 1 + 2 files changed, 26 insertions(+) create mode 100644 docs/source/reference/db.rst diff --git a/docs/source/reference/db.rst b/docs/source/reference/db.rst new file mode 100644 index 00000000..d2fb55ad --- /dev/null +++ b/docs/source/reference/db.rst @@ -0,0 +1,25 @@ + +.. py:module:: clickgen.db +.. py:currentmodule:: clickgen.db + +:py:mod:`~clickgen.db` Module +=============================== + +This module provides **Cursor** database along symlinks supports. + + +Classes +------- +.. autoclass:: clickgen.db.CursorDB +.. automethod:: clickgen.db.CursorDB.__init__ +.. automethod:: clickgen.db.CursorDB.search_symlinks +.. automethod:: clickgen.db.CursorDB.rename_file + + +Constants +--------- + +.. data:: DATA + + Default dataset of XCursor in ``clickgen``. + diff --git a/docs/source/reference/index.rst b/docs/source/reference/index.rst index a4ec8d7a..3a274023 100644 --- a/docs/source/reference/index.rst +++ b/docs/source/reference/index.rst @@ -4,3 +4,4 @@ util + db From 899acb1991f21997cdbbc306b01f58b5a0a12d81 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Thu, 11 Mar 2021 18:05:51 +0530 Subject: [PATCH 26/53] =?UTF-8?q?=E2=84=B9=EF=B8=8F=20=20Module=20docs=20a?= =?UTF-8?q?dded=20`clickgen.packagers`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/reference/db.rst | 2 +- docs/source/reference/index.rst | 1 + docs/source/reference/packagers.rst | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 docs/source/reference/packagers.rst diff --git a/docs/source/reference/db.rst b/docs/source/reference/db.rst index d2fb55ad..5627eb28 100644 --- a/docs/source/reference/db.rst +++ b/docs/source/reference/db.rst @@ -3,7 +3,7 @@ .. py:currentmodule:: clickgen.db :py:mod:`~clickgen.db` Module -=============================== +============================= This module provides **Cursor** database along symlinks supports. diff --git a/docs/source/reference/index.rst b/docs/source/reference/index.rst index 3a274023..9600ca61 100644 --- a/docs/source/reference/index.rst +++ b/docs/source/reference/index.rst @@ -5,3 +5,4 @@ util db + packagers diff --git a/docs/source/reference/packagers.rst b/docs/source/reference/packagers.rst new file mode 100644 index 00000000..dbe8dc2f --- /dev/null +++ b/docs/source/reference/packagers.rst @@ -0,0 +1,15 @@ + +.. py:module:: clickgen.packagers +.. py:currentmodule:: clickgen.packagers + +:py:mod:`~clickgen.packagers` Module +==================================== + +Using this module you are able to create ``Windows`` or ``Unix`` cursor packages. + + +Functions +--------- + +.. autofunction:: XPackager +.. autofunction:: WindowsPackager From 797c955b14e6c9a540b0c16e2e8a349833f65d77 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Thu, 11 Mar 2021 18:06:23 +0530 Subject: [PATCH 27/53] =?UTF-8?q?=F0=9F=93=9A=20parameters=20docs=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/packagers.py | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/clickgen/packagers.py b/clickgen/packagers.py index f3d98c8b..6e842b6d 100644 --- a/clickgen/packagers.py +++ b/clickgen/packagers.py @@ -17,7 +17,22 @@ def XPackager(directory: Path, theme_name: str, comment: str) -> None: - """ Create a crispy `XCursors` theme package. """ + """Create a crispy `XCursors` theme package. + + This packager generates ``cursor.theme`` & ``index.theme`` files at ``directory``. + + :param directory: Path where ``.theme`` files save. + :param directory: Path + + :param theme_name: Cursor theme name. + :param theme_name: str + + :param comment: Extra information about this cursor theme. + :param comment: str + + :returns: Nothing + :rtype: None + """ # Writing all .theme files files: Dict[str, str] = {} @@ -113,7 +128,28 @@ def WindowsPackager( author: str, website_url: Optional[str] = None, ) -> None: - """ Create a crispy `Windows` cursor theme package. """ + """Create a crispy `Windows` cursor theme package. + + This packager generates ``install.inf`` files at ``directory``. Also, Cursor extensions is identified by its type (.cur/.ani). + + :param directory: Path where ``.theme`` files save. + :param directory: Path + + :param theme_name: Cursor theme name. + :param theme_name: str + + :param comment: Extra information about this cursor theme. + :param comment: str + + :param author: Author name. + :param author: str + + :param website_url: Website web address.(Useful for **bug reports**) + :param author: str (, optional) + + :returns: Nothing + :rtype: None + """ files: List[Path] = [] From 40a144bea70f74fd83e404a539f61d1b8593f3f3 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 13 Mar 2021 16:35:48 +0530 Subject: [PATCH 28/53] =?UTF-8?q?=F0=9F=93=9A=20Packagers=20docs=20string?= =?UTF-8?q?=20formated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/packagers.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/clickgen/packagers.py b/clickgen/packagers.py index 6e842b6d..e639cd71 100644 --- a/clickgen/packagers.py +++ b/clickgen/packagers.py @@ -17,9 +17,7 @@ def XPackager(directory: Path, theme_name: str, comment: str) -> None: - """Create a crispy `XCursors` theme package. - - This packager generates ``cursor.theme`` & ``index.theme`` files at ``directory``. + """This packager generates ``cursor.theme`` & ``index.theme`` files at ``directory``. :param directory: Path where ``.theme`` files save. :param directory: Path @@ -128,9 +126,7 @@ def WindowsPackager( author: str, website_url: Optional[str] = None, ) -> None: - """Create a crispy `Windows` cursor theme package. - - This packager generates ``install.inf`` files at ``directory``. Also, Cursor extensions is identified by its type (.cur/.ani). + """This packager generates ``install.inf`` files at ``directory``. Also, Cursor extensions is identified by its type (.cur/.ani). :param directory: Path where ``.theme`` files save. :param directory: Path From f144d86f36272061a51e53502949026eaf631e04 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 13 Mar 2021 16:36:17 +0530 Subject: [PATCH 29/53] =?UTF-8?q?=F0=9F=94=97=20Reference=20heading=20adde?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/reference/index.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/reference/index.rst b/docs/source/reference/index.rst index 9600ca61..f5bc7cae 100644 --- a/docs/source/reference/index.rst +++ b/docs/source/reference/index.rst @@ -1,3 +1,5 @@ +Reference +========= .. toctree:: :maxdepth: 2 From 4fac1bcbba8d35d498871f83395439f860173afb Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Mon, 15 Mar 2021 19:56:43 +0530 Subject: [PATCH 30/53] =?UTF-8?q?=F0=9F=93=9A=20Core=20module=20docs=20ini?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/reference/core.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 docs/source/reference/core.rst diff --git a/docs/source/reference/core.rst b/docs/source/reference/core.rst new file mode 100644 index 00000000..451fc50d --- /dev/null +++ b/docs/source/reference/core.rst @@ -0,0 +1,6 @@ + +.. py:module:: clickgen.core +.. py:currentmodule:: clickgen.core + +:py:mod:`~clickgen.core` Module +=============================== From 67ad984caf72d71949b19a496c95cba2d5fab19b Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Mon, 15 Mar 2021 20:34:32 +0530 Subject: [PATCH 31/53] =?UTF-8?q?=F0=9F=92=8C=20"clickgen.core.Bitmap"=20d?= =?UTF-8?q?ocstring=20setup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/core.py | 6 ++++++ docs/source/reference/core.rst | 4 ++++ docs/source/reference/index.rst | 1 + 3 files changed, 11 insertions(+) diff --git a/clickgen/core.py b/clickgen/core.py index d621163d..464784a1 100644 --- a/clickgen/core.py +++ b/clickgen/core.py @@ -19,6 +19,12 @@ class Bitmap(object): + """The ``Bitmap`` class is used to represent a ``.png`` or sequences of + ``.png`` image. The class also provides a number of factory functions, + including functions to **rename** ``.png`` images from files, and + **reproduce** size of same image/s. + """ + animated: bool png: Path grouped_png: List[Path] diff --git a/docs/source/reference/core.rst b/docs/source/reference/core.rst index 451fc50d..7b50912f 100644 --- a/docs/source/reference/core.rst +++ b/docs/source/reference/core.rst @@ -4,3 +4,7 @@ :py:mod:`~clickgen.core` Module =============================== + +Classes +------- +.. autoclass:: clickgen.core.Bitmap diff --git a/docs/source/reference/index.rst b/docs/source/reference/index.rst index f5bc7cae..451c5740 100644 --- a/docs/source/reference/index.rst +++ b/docs/source/reference/index.rst @@ -5,6 +5,7 @@ Reference :maxdepth: 2 + core util db packagers From 0401a2a2a9da1455263dd9999d77ca39ca933452 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 16 Mar 2021 19:09:54 +0530 Subject: [PATCH 32/53] =?UTF-8?q?=F0=9F=92=9D=20"clickgen.core.Bitmap"=20c?= =?UTF-8?q?lass=20&=20it's=20init=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/core.py | 17 ++++++++++++++--- docs/source/reference/core.rst | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/clickgen/core.py b/clickgen/core.py index 464784a1..172795d5 100644 --- a/clickgen/core.py +++ b/clickgen/core.py @@ -19,9 +19,9 @@ class Bitmap(object): - """The ``Bitmap`` class is used to represent a ``.png`` or sequences of - ``.png`` image. The class also provides a number of factory functions, - including functions to **rename** ``.png`` images from files, and + """The ``Bitmap`` class is used to represent a ``.png`` or sequences of \ + ``.png`` image. The class also provides a number of factory functions, \ + including functions to **rename** ``.png`` images from files, and \ **reproduce** size of same image/s. """ @@ -45,6 +45,17 @@ def __init__( png: Union[LikePath, LikePathList], hotspot: Tuple[int, int], ) -> None: + """ + :param png: File location. Use ``List`` for animated Cursor. + :type png: Union[LikePath, LikePathList] + + :param hotspot: Hotspot is coordinate value in Tuple. Cursor change \ + state is calculated from this value. + :type hotspot: Tuple[int, int] + + :raise TypeError: If provided ``.png`` file/s location is not type **str** \ + or **pathlib.Path** + """ super().__init__() # Is png == _P => 'static' bitmap diff --git a/docs/source/reference/core.rst b/docs/source/reference/core.rst index 7b50912f..98b31b5c 100644 --- a/docs/source/reference/core.rst +++ b/docs/source/reference/core.rst @@ -8,3 +8,4 @@ Classes ------- .. autoclass:: clickgen.core.Bitmap +.. automethod:: clickgen.core.Bitmap.__init__ From 089fe058d9993723eb53436f0659479bec536a87 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 16 Mar 2021 19:29:40 +0530 Subject: [PATCH 33/53] =?UTF-8?q?=E2=9C=85=20"clickgen.core.Bitmap"=20cons?= =?UTF-8?q?truction=20private=20methods=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/core.py | 30 +++++++++++++++++++++++++----- docs/source/reference/core.rst | 4 ++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/clickgen/core.py b/clickgen/core.py index 172795d5..cff9ac02 100644 --- a/clickgen/core.py +++ b/clickgen/core.py @@ -53,8 +53,8 @@ def __init__( state is calculated from this value. :type hotspot: Tuple[int, int] - :raise TypeError: If provided ``.png`` file/s location is not type **str** \ - or **pathlib.Path** + :raise TypeError: If provided ``.png`` file/s location is not type \ + **str** or **pathlib.Path** """ super().__init__() @@ -63,9 +63,8 @@ def __init__( # Or png == [_P] => 'static' bitmap # else TypeError() - err: str = ( - f"argument should be a 'str' object or 'Path' object , not {type(png)}" - ) + err: str = f"argument should be a 'str' object or 'Path' object , not \ + {type(png)}" if isinstance(png, (str, Path)): self.__set_as_static(png, hotspot) @@ -101,6 +100,17 @@ def __exit__(self, exception_type, exception_value, traceback): # type: ignore # Private methods # def __set_as_static(self, png: LikePath, hotspot: Tuple[int, int]) -> None: + """Set this Bitmap as **static**, It means this bitmap hold single ``png``. + + .. note:: This method called by ``self.__init__``. + + :param png: ``.png`` file location. + :type png: Union[str,Path] + + :param hotspot: Hotspot is coordinate value in Tuple. Cursor change \ + state is calculated from this value. + :type hotspot: Tuple[int, int] + """ self.png = self._check_bitmap(png) self._set_key(self.png, check=False) self._set_size(self.png) @@ -108,7 +118,17 @@ def __set_as_static(self, png: LikePath, hotspot: Tuple[int, int]) -> None: self.animated = False def __set_as_animated(self, png: LikePathList, hotspot: Tuple[int, int]) -> None: + """Set this Bitmap as **animated**, It means this bitmap holds multiple ``png``. + + .. note:: This method called by ``self.__init__``. + :param png: ``.png`` file location ***List***. + :type png: List[Union[str,Path]] + + :param hotspot: Hotspot is coordinate value in Tuple. Cursor change \ + state is calculated from this value. + :type hotspot: Tuple[int, int] + """ self.grouped_png = [] for p in png: frame: Path = self._check_bitmap(p) diff --git a/docs/source/reference/core.rst b/docs/source/reference/core.rst index 98b31b5c..869c6ba8 100644 --- a/docs/source/reference/core.rst +++ b/docs/source/reference/core.rst @@ -9,3 +9,7 @@ Classes ------- .. autoclass:: clickgen.core.Bitmap .. automethod:: clickgen.core.Bitmap.__init__ +.. automethod:: clickgen.core.Bitmap.__str__ +.. automethod:: clickgen.core.Bitmap.__repr__ +.. automethod:: clickgen.core.Bitmap.__set_as_static +.. automethod:: clickgen.core.Bitmap.__set_as_animated From b4093c97b916cb58bcc5e7200f81864f1736a4c3 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 16 Mar 2021 19:56:15 +0530 Subject: [PATCH 34/53] =?UTF-8?q?=F0=9F=92=85=20Prettier=20notes=20&=20hea?= =?UTF-8?q?dlines?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/core.py | 4 ++-- docs/source/reference/core.rst | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/clickgen/core.py b/clickgen/core.py index cff9ac02..5a3b5edf 100644 --- a/clickgen/core.py +++ b/clickgen/core.py @@ -102,7 +102,7 @@ def __exit__(self, exception_type, exception_value, traceback): # type: ignore def __set_as_static(self, png: LikePath, hotspot: Tuple[int, int]) -> None: """Set this Bitmap as **static**, It means this bitmap hold single ``png``. - .. note:: This method called by ``self.__init__``. + .. note:: This method called by ``self.__init__``. :param png: ``.png`` file location. :type png: Union[str,Path] @@ -120,7 +120,7 @@ def __set_as_static(self, png: LikePath, hotspot: Tuple[int, int]) -> None: def __set_as_animated(self, png: LikePathList, hotspot: Tuple[int, int]) -> None: """Set this Bitmap as **animated**, It means this bitmap holds multiple ``png``. - .. note:: This method called by ``self.__init__``. + .. note:: This method called by ``self.__init__``. :param png: ``.png`` file location ***List***. :type png: List[Union[str,Path]] diff --git a/docs/source/reference/core.rst b/docs/source/reference/core.rst index 869c6ba8..f6665805 100644 --- a/docs/source/reference/core.rst +++ b/docs/source/reference/core.rst @@ -5,11 +5,11 @@ :py:mod:`~clickgen.core` Module =============================== -Classes -------- +:py:mod:`~clickgen.core.Bitmap` Class +------------------------------------- .. autoclass:: clickgen.core.Bitmap .. automethod:: clickgen.core.Bitmap.__init__ -.. automethod:: clickgen.core.Bitmap.__str__ -.. automethod:: clickgen.core.Bitmap.__repr__ .. automethod:: clickgen.core.Bitmap.__set_as_static .. automethod:: clickgen.core.Bitmap.__set_as_animated +.. automethod:: clickgen.core.Bitmap.__str__ +.. automethod:: clickgen.core.Bitmap.__repr__ From 095eed88ddae40d6b1cad60a1b7fbe726975a6dc Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Tue, 16 Mar 2021 19:56:54 +0530 Subject: [PATCH 35/53] =?UTF-8?q?=F0=9F=94=A5=20Headlines=20links=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/reference/db.rst | 6 ++---- docs/source/reference/packagers.rst | 10 +++++----- docs/source/reference/util.rst | 27 ++++++++++++++++----------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/docs/source/reference/db.rst b/docs/source/reference/db.rst index 5627eb28..40264ddc 100644 --- a/docs/source/reference/db.rst +++ b/docs/source/reference/db.rst @@ -7,9 +7,8 @@ This module provides **Cursor** database along symlinks supports. - -Classes -------- +:py:class:`~clickgen.db.CursorDB` Class +--------------------------------------- .. autoclass:: clickgen.db.CursorDB .. automethod:: clickgen.db.CursorDB.__init__ .. automethod:: clickgen.db.CursorDB.search_symlinks @@ -18,7 +17,6 @@ Classes Constants --------- - .. data:: DATA Default dataset of XCursor in ``clickgen``. diff --git a/docs/source/reference/packagers.rst b/docs/source/reference/packagers.rst index dbe8dc2f..c869621b 100644 --- a/docs/source/reference/packagers.rst +++ b/docs/source/reference/packagers.rst @@ -4,12 +4,12 @@ :py:mod:`~clickgen.packagers` Module ==================================== - Using this module you are able to create ``Windows`` or ``Unix`` cursor packages. - -Functions ---------- - +:py:mod:`~clickgen.packagers.XPackager` +--------------------------------------- .. autofunction:: XPackager + +:py:mod:`~clickgen.packagers.WindowsPackager` +--------------------------------------------- .. autofunction:: WindowsPackager diff --git a/docs/source/reference/util.rst b/docs/source/reference/util.rst index 6ea51f94..75b09a5f 100644 --- a/docs/source/reference/util.rst +++ b/docs/source/reference/util.rst @@ -6,26 +6,31 @@ This module provides utility functions and classes, Which makes developer life easier. - -Classes -------- +:py:class:`~clickgen.util.pngprovider` class +-------------------------------------------- .. autoclass:: clickgen.util.PNGProvider .. automethod:: clickgen.util.PNGProvider.get -Functions ---------- - -Add missing ``Xcursor`` -^^^^^^^^^^^^^^^^^^^^^^^ +:py:mod:`~clickgen.util.add_missing_xcursors` function +------------------------------------------------------ .. autofunction:: add_missing_xcursors Utility -^^^^^^^ +------- + +:py:mod:`~clickgen.util.chdir` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. autofunction:: chdir + +:py:mod:`~clickgen.util.remove_util` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. autofunction:: remove_util -For developer only -^^^^^^^^^^^^^^^^^^ +:py:mod:`~clickgen.util.timer` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. autofunction:: timer + +:py:mod:`~clickgen.util.debug` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. autofunction:: debug From f8c1a1429eeb015361d7f8c3b50eba4b9699a2c2 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Wed, 17 Mar 2021 18:34:26 +0530 Subject: [PATCH 36/53] =?UTF-8?q?=F0=9F=90=8D=20"clickgen.core.Bitmap"=20p?= =?UTF-8?q?rivate=20method=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/core.py | 62 ++++++++++++++++++++++++++++++++++ docs/source/reference/core.rst | 4 +++ 2 files changed, 66 insertions(+) diff --git a/clickgen/core.py b/clickgen/core.py index 5a3b5edf..746ddc62 100644 --- a/clickgen/core.py +++ b/clickgen/core.py @@ -55,6 +55,7 @@ def __init__( :raise TypeError: If provided ``.png`` file/s location is not type \ **str** or **pathlib.Path** + """ super().__init__() @@ -110,6 +111,13 @@ def __set_as_static(self, png: LikePath, hotspot: Tuple[int, int]) -> None: :param hotspot: Hotspot is coordinate value in Tuple. Cursor change \ state is calculated from this value. :type hotspot: Tuple[int, int] + + :raise FileNotFoundError: If ``.png`` file not found + :raise ValueError: If provided bitmap is not ``.png`` + :raise ValueError: If image width & height are not same + :raise ValueError: If grouped ``.png`` files naming is invalid + :raise ValueError: If hotspot is set higher or lower then image pixels + """ self.png = self._check_bitmap(png) self._set_key(self.png, check=False) @@ -128,6 +136,13 @@ def __set_as_animated(self, png: LikePathList, hotspot: Tuple[int, int]) -> None :param hotspot: Hotspot is coordinate value in Tuple. Cursor change \ state is calculated from this value. :type hotspot: Tuple[int, int] + + :raise FileNotFoundError: If ``.png`` file not found + :raise ValueError: If provided bitmap is not ``.png`` + :raise ValueError: If image width & height are not same + :raise ValueError: If grouped ``.png`` files naming is invalid + :raise ValueError: If hotspot is set higher or lower then image pixels + """ self.grouped_png = [] for p in png: @@ -147,6 +162,18 @@ def __set_as_animated(self, png: LikePathList, hotspot: Tuple[int, int]) -> None # Protected methods # def _check_bitmap(self, bmp_path: LikePath) -> Path: + """Checks bitmap is supported by clickgen. + + :param bmp_path: Bitmap file location. + :type bmp_path: Union[str, Path] + + :raise FileNotFoundError: If ``.png`` file not found + :raise ValueError: If provided bitmap is not ``.png`` + + :returns: Return the ``pathlib.Path`` instant, If provided **bitmap path** checks passed. + :rtype: Path + + """ p: Path = Path(bmp_path) if not p.exists(): raise FileNotFoundError( @@ -163,6 +190,17 @@ def _check_bitmap(self, bmp_path: LikePath) -> Path: return p def _set_size(self, bmp_path: Path, prev_check: bool = True) -> None: + """Set or overwrite size of this bitmap. + + :param bmp_path: Bitmap file location. + :type bmp_path: Path + + :param prev_check: If you want to match size with previous size. This flag is useful for grouped ``png``.(@default True ) + :type prev_check: bool + + :raise ValueError: If image width & height are not same + + """ with Img.open(bmp_path) as i: def __set() -> None: @@ -188,6 +226,15 @@ def __set() -> None: ) def _set_key(self, bmp_path: Path, check: bool) -> None: + """Set unique identity for this bitmap. + + :param bmp_path: Bitmap file location. + :type bmp_path: Path + + :param check: If you want sure multiple ``png`` files identity is same + :type check: bool + + """ if check: try: k, _ = bmp_path.stem.rsplit("-", 1) @@ -208,6 +255,15 @@ def _set_key(self, bmp_path: Path, check: bool) -> None: self.key = bmp_path.stem def _set_hotspot(self, img_path: Path, hotspot: Tuple[int, int]) -> None: + """Set this bitmap reaction state. + + :param img_path: Bitmap file location. + :type img_path: Path + + :param hotspot: ``xy`` coordinates for this bitmap. + :type hotspot: Tuple[int, int] + + """ x = hotspot[0] y = hotspot[1] with Img.open(img_path) as i: @@ -221,6 +277,12 @@ def _set_hotspot(self, img_path: Path, hotspot: Tuple[int, int]) -> None: self.y_hot = y def _update_hotspots(self, new_size: Size) -> None: + """Update this bitmap reaction state. + + :param new_size: Bitmap width & height tuple (in pixel) + :type new_size: Tuple[int, int] + + """ if self.size != new_size: self.x_hot = int(round(new_size[0] / self.width * self.x_hot)) self.y_hot = int(round(new_size[1] / self.height * self.y_hot)) diff --git a/docs/source/reference/core.rst b/docs/source/reference/core.rst index f6665805..3a4ddb12 100644 --- a/docs/source/reference/core.rst +++ b/docs/source/reference/core.rst @@ -11,5 +11,9 @@ .. automethod:: clickgen.core.Bitmap.__init__ .. automethod:: clickgen.core.Bitmap.__set_as_static .. automethod:: clickgen.core.Bitmap.__set_as_animated +.. automethod:: clickgen.core.Bitmap._check_bitmap +.. automethod:: clickgen.core.Bitmap._set_hotspot +.. automethod:: clickgen.core.Bitmap._update_hotspots +.. automethod:: clickgen.core.Bitmap._set_key .. automethod:: clickgen.core.Bitmap.__str__ .. automethod:: clickgen.core.Bitmap.__repr__ From ac8d3273453d901f1ca14e129be480bb837a8da1 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Wed, 17 Mar 2021 19:34:32 +0530 Subject: [PATCH 37/53] =?UTF-8?q?=F0=9F=93=A6=20complete=20clickgen.core.B?= =?UTF-8?q?itmap=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/core.py | 70 ++++++++++++++++++++++++++++++---- docs/source/reference/core.rst | 10 ++--- 2 files changed, 66 insertions(+), 14 deletions(-) diff --git a/clickgen/core.py b/clickgen/core.py index 746ddc62..bd35a400 100644 --- a/clickgen/core.py +++ b/clickgen/core.py @@ -19,7 +19,7 @@ class Bitmap(object): - """The ``Bitmap`` class is used to represent a ``.png`` or sequences of \ + """The ``Bitmap`` class is used to represent a ``.png`` or sequences of ``.png`` image. The class also provides a number of factory functions, \ including functions to **rename** ``.png`` images from files, and \ **reproduce** size of same image/s. @@ -55,7 +55,6 @@ def __init__( :raise TypeError: If provided ``.png`` file/s location is not type \ **str** or **pathlib.Path** - """ super().__init__() @@ -117,7 +116,6 @@ def __set_as_static(self, png: LikePath, hotspot: Tuple[int, int]) -> None: :raise ValueError: If image width & height are not same :raise ValueError: If grouped ``.png`` files naming is invalid :raise ValueError: If hotspot is set higher or lower then image pixels - """ self.png = self._check_bitmap(png) self._set_key(self.png, check=False) @@ -142,7 +140,6 @@ def __set_as_animated(self, png: LikePathList, hotspot: Tuple[int, int]) -> None :raise ValueError: If image width & height are not same :raise ValueError: If grouped ``.png`` files naming is invalid :raise ValueError: If hotspot is set higher or lower then image pixels - """ self.grouped_png = [] for p in png: @@ -172,7 +169,6 @@ def _check_bitmap(self, bmp_path: LikePath) -> Path: :returns: Return the ``pathlib.Path`` instant, If provided **bitmap path** checks passed. :rtype: Path - """ p: Path = Path(bmp_path) if not p.exists(): @@ -199,7 +195,6 @@ def _set_size(self, bmp_path: Path, prev_check: bool = True) -> None: :type prev_check: bool :raise ValueError: If image width & height are not same - """ with Img.open(bmp_path) as i: @@ -234,6 +229,8 @@ def _set_key(self, bmp_path: Path, check: bool) -> None: :param check: If you want sure multiple ``png`` files identity is same :type check: bool + :raise ValueError: If grouped png indexing invalid. + :raise ValueError: If new identity not matched with old. """ if check: try: @@ -262,7 +259,6 @@ def _set_hotspot(self, img_path: Path, hotspot: Tuple[int, int]) -> None: :param hotspot: ``xy`` coordinates for this bitmap. :type hotspot: Tuple[int, int] - """ x = hotspot[0] y = hotspot[1] @@ -281,7 +277,6 @@ def _update_hotspots(self, new_size: Size) -> None: :param new_size: Bitmap width & height tuple (in pixel) :type new_size: Tuple[int, int] - """ if self.size != new_size: self.x_hot = int(round(new_size[0] / self.width * self.x_hot)) @@ -296,6 +291,24 @@ def resize( resample: int = Img.NONE, save: bool = True, ) -> Optional[Union[Image, List[Image]]]: + """Resize this bitmap. + + :param size: New width & height in pixel. + :type size: Tuple[int, int] + + :param resample: Pillow resample algorithm. + :type resample: int + + :param save: If you want to overwrite resized bitmap to actual png file. \ + Neither it return pillow ``Image`` buffer. + :type save: bool + + :returns: Returns image buffers, If *save* flag is set to ``False`` + :rtype: Optional[Union[Image, List[Image]]] + + :raise ValueError: If image width & height are not same. + """ + def __resize(p: Path, frame: int) -> Image: img: Image = Img.open(p) @@ -331,6 +344,27 @@ def reproduce( position: str = "center", save=True, ) -> Optional[Union[Image, List[Image]]]: + """Resize bitmap with more options. + + :param size: Bitmap width & height in pixel. + :type size: Tuple[int, int] + + :param canvas_size: Bitmap's canvas width & height in pixel. + :type canvas_size: Tuple[int, int] + + :param position: Bitmap's canvas width & height in pixel. (@default "center") + :type position: "center" | "top_left" | "top_right" | "bottom_left" | "bottom_right" + + :param save: If you want to overwrite resized bitmap to actual png \ + file. Neither it return pillow ``Image`` buffer. + :type save: bool + + :returns: Returns image buffers, If *save* flag is set to ``False`` + :rtype: Optional[Union[Image, List[Image]]] + + :raise ValueError: If image width & height are not same. + """ + def __reproduce(p: Path) -> Image: frame: Image = Img.open(p).resize(size, resample=Img.BICUBIC) x, y = tuple(map(lambda i, j: i - j, canvas_size, size)) @@ -369,6 +403,14 @@ def __reproduce(p: Path) -> Image: return None def rename(self, key: str) -> None: + """Rename unique identity of bitmap. + + :param key: Bitmap unique identity. + :type key: str + + :raise ValueError: If grouped png indexing invalid. + :raise ValueError: If new identity not matched with old. + """ old_key = self.key if key != old_key: @@ -389,6 +431,18 @@ def __rename(png: Path, check: bool) -> Path: self.png = __rename(self.png, check=False) def copy(self, path: Optional[LikePath] = None) -> "Bitmap": + """Generate deepcopy of this bitmap. + + :param path: Provide custom path to store deepcopy bitmaps. \ + Set ``None`` to store in temporary directory. \ + (@default None) + :type path: str + + :returns: deepcopy of this bitmap state. + :rtype: Bitmap + + :raise NotADirectoryError: If provided path is not directory. + """ if not path: p_obj: Path = Path(mkdtemp(prefix=f"{self.key}__copy__")) else: diff --git a/docs/source/reference/core.rst b/docs/source/reference/core.rst index 3a4ddb12..3958d566 100644 --- a/docs/source/reference/core.rst +++ b/docs/source/reference/core.rst @@ -9,11 +9,9 @@ ------------------------------------- .. autoclass:: clickgen.core.Bitmap .. automethod:: clickgen.core.Bitmap.__init__ -.. automethod:: clickgen.core.Bitmap.__set_as_static -.. automethod:: clickgen.core.Bitmap.__set_as_animated -.. automethod:: clickgen.core.Bitmap._check_bitmap -.. automethod:: clickgen.core.Bitmap._set_hotspot -.. automethod:: clickgen.core.Bitmap._update_hotspots -.. automethod:: clickgen.core.Bitmap._set_key +.. automethod:: clickgen.core.Bitmap.resize +.. automethod:: clickgen.core.Bitmap.rename +.. automethod:: clickgen.core.Bitmap.reproduce +.. automethod:: clickgen.core.Bitmap.copy .. automethod:: clickgen.core.Bitmap.__str__ .. automethod:: clickgen.core.Bitmap.__repr__ From 7688564dfcb26b527fdf843359380d5e512de240 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Wed, 17 Mar 2021 19:36:15 +0530 Subject: [PATCH 38/53] =?UTF-8?q?=F0=9F=92=9D=20Init=20clickgen.core.Curso?= =?UTF-8?q?rAlias=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/reference/core.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/source/reference/core.rst b/docs/source/reference/core.rst index 3958d566..0aa00c69 100644 --- a/docs/source/reference/core.rst +++ b/docs/source/reference/core.rst @@ -15,3 +15,8 @@ .. automethod:: clickgen.core.Bitmap.copy .. automethod:: clickgen.core.Bitmap.__str__ .. automethod:: clickgen.core.Bitmap.__repr__ + +:py:mod:`~clickgen.core.CursorAlias` Class +------------------------------------------ +.. autoclass:: clickgen.core.CursorAlias +.. automethod:: clickgen.core.CursorAlias.__init__ From 30d391c30e80668a4c1a3f2c7e47be57e29ac249 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Thu, 18 Mar 2021 18:29:38 +0530 Subject: [PATCH 39/53] =?UTF-8?q?=F0=9F=92=8C=20Init=20"clickgen.core.Curs?= =?UTF-8?q?orAlias"=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/core.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/clickgen/core.py b/clickgen/core.py index bd35a400..07e45537 100644 --- a/clickgen/core.py +++ b/clickgen/core.py @@ -475,10 +475,16 @@ class CursorAlias(object): alias_file: Path garbage_dirs: List[Path] = [] + """Cursor Config ``.in`` or ``.alias`` file provider.""" + def __init__( self, bitmap: Bitmap, ) -> None: + """ + :param bitmap: Cursor ``clickgen.core.Bitmap`` instant. + :type bitmap: Bitmap + """ super().__init__() self.bitmap = bitmap @@ -486,6 +492,10 @@ def __init__( self.alias_dir = Path(mkdtemp(prefix=self.prefix)) def __get_alias_file(self) -> Optional[Path]: + """ + :returns: Return cursor alias file path, If it's exists. + :rtype: Optional[Path] + """ if hasattr(self, "alias_file"): return self.alias_file return None From 324af208a5f90edea85b7db23a98db1ff05a94fd Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Thu, 18 Mar 2021 19:01:31 +0530 Subject: [PATCH 40/53] =?UTF-8?q?=F0=9F=92=BE=20Classmethods=20docs=20stri?= =?UTF-8?q?ng=20"clickgen.core.CursorAlias"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/core.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/clickgen/core.py b/clickgen/core.py index 07e45537..4d473860 100644 --- a/clickgen/core.py +++ b/clickgen/core.py @@ -482,7 +482,7 @@ def __init__( bitmap: Bitmap, ) -> None: """ - :param bitmap: Cursor ``clickgen.core.Bitmap`` instant. + :param bitmap: Cursor :py:class:`~clickgen.core.Bitmap` instant. :type bitmap: Bitmap """ super().__init__() @@ -525,6 +525,18 @@ def from_bitmap( png: Union[LikePath, LikePathList], hotspot: Tuple[int, int], ) -> "CursorAlias": + """Create cursor alias config file from ``.png`` files instant. + + :param png: File location. Use ``List`` for animated Cursor. + :type png: Union[LikePath, LikePathList] + + :param hotspot: Hotspot is coordinate value in Tuple. Cursor change \ + state is calculated from this value. + :type hotspot: Tuple[int, int] + + :raise TypeError: If provided ``.png`` file/s location is not type \ + **str** or **pathlib.Path** + """ bmp: Bitmap = Bitmap(png, hotspot) return cls(bmp) From fd42b8d344f400bd1feb33512744112ea21fd358 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Thu, 18 Mar 2021 19:51:13 +0530 Subject: [PATCH 41/53] =?UTF-8?q?=F0=9F=93=9A=20"clickgen.core"=20docstrin?= =?UTF-8?q?g=20finished?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- clickgen/core.py | 94 +++++++++++++++++++++++++++++++++- docs/source/reference/core.rst | 7 +++ 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/clickgen/core.py b/clickgen/core.py index 4d473860..6ec96729 100644 --- a/clickgen/core.py +++ b/clickgen/core.py @@ -545,6 +545,22 @@ def create( sizes: Union[Size, List[Size]], delay: int = 10, ) -> Path: + """Generate and store cursor's config file at ``temporary`` storage. + + :param sizes: Cursor pixel size tuple. + :type sizes: Union[Tuple[int, int], List[Tuple[int, int]]] + + :param delay: Delay between every cursor frame.(Affect on only \ + animated :py:class:`~clickgen.core.Bitmap`) + :type delay: int + + :returns: Cursor alias file path. + :rtype: Path + + :raise TypeError: If provided ``size`` is not type of Tuple[int, int] \ + or List of Tuple[int, int] + """ + def __generate(size: Size) -> List[str]: d: Path = self.alias_dir / f"{size[0]}x{size[1]}" @@ -604,10 +620,27 @@ def __write_alias(lines: List[str]) -> None: return self.alias_file def check_alias(self) -> None: + """Checks cursor config file exists on filesystem. + + :raise FileNotFoundError: If cursor config file not generate. \ + Calling :py:meth:`~clickgen.core.CursorAlias.create` to \ + recreate it. + """ if not any(self.alias_dir.iterdir()): raise FileNotFoundError("Alias directory is empty or not exists.") - def extension(self, ext: Optional[str] = None) -> LikePath: + def extension(self, ext: Optional[str] = None) -> Union[str, Path]: + """``get`` or ``change`` cursor config file extension. This method helps \ + to change default config extension ``.alias`` to ``.in``. + + :param ext: Provide custom cursor's config file extension. Like \ + ``o.extension(ext = ".in")``. (@default None) + :type ext: Optional[str] + + :returns: Provide ``None`` value to retrieve current extension. \ + Either returns the updated cursor's config file path. + :rtype: Union[str, Path] + """ self.check_alias() if ext: new_path: Path = self.alias_file.with_suffix(ext) @@ -617,6 +650,24 @@ def extension(self, ext: Optional[str] = None) -> LikePath: return self.alias_file.suffix def copy(self, dst: Optional[LikePath] = None) -> "CursorAlias": + """Copy current bitmap config to directory. + + .. note:: + This method **creates** the ``dst`` directory if not exists. + + :param dst: Custom directory path for store deepcopy of cursor config \ + file and it's bitmaps. Provide ``None`` value to store at \ + temporary storage. + :type dst: Optional[Union[str, Path]] + + :returns: deepcopy object of current ``CursorAlias`` state. + :rtype: CursorAlias + + :raise FileNotFoundError: If cursor config file not generate. \ + Calling :py:meth:`~clickgen.core.CursorAlias.create` to \ + recreate it. + :raise NotADirectoryError: If provided ``dst`` is not a directory. + """ self.check_alias() if not dst: @@ -638,6 +689,24 @@ def copy(self, dst: Optional[LikePath] = None) -> "CursorAlias": return replica_object def rename(self, key: str) -> Path: + """Rename current cursor's config file. + + Renaming cursor config is affects naming of bitmaps. \ + This method is calls :py:meth:`~clickgen.core.Bitmap.rename` \ + internaly for renaming bitmaps name. + + :param key: Unique identity. + :type key: str + + :returns: Renamed config file path. + :rtype: Path + + :raise FileNotFoundError: If cursor config file not generate. \ + Calling :py:meth:`~clickgen.core.CursorAlias.create` to \ + recreate it. + :raise ValueError: If grouped png indexing invalid. + :raise ValueError: If new identity not matched with old. + """ self.check_alias() old_key: str = self.bitmap.key @@ -675,6 +744,29 @@ def reproduce( position: str = "center", delay: int = 3, ) -> "CursorAlias": + """Resize cursor config and bitmap. + + :param size: Bitmap width & height in pixel. + :type size: Tuple[int, int] + + :param canvas_size: Bitmap's canvas width & height in pixel. + :type canvas_size: Tuple[int, int] + + :param position: Bitmap's canvas width & height in pixel. (@default "center") + :type position: "center" | "top_left" | "top_right" | "bottom_left" | "bottom_right" + + :param save: If you want to overwrite resized bitmap to actual png \ + file. Neither it return pillow ``Image`` buffer. + :type save: bool + + :returns: Returns reproduced ``CursorAlias`` object. + :rtype: CursorAlias + + :raise FileNotFoundError: If cursor config file not generate. \ + Calling :py:meth:`~clickgen.core.CursorAlias.create` to \ + recreate it. + :raise ValueError: If image width & height are not same. + """ self.check_alias() tmp_bitmaps_dir: Path = Path(mkdtemp(prefix=f"{self.prefix}__garbage_bmps__")) diff --git a/docs/source/reference/core.rst b/docs/source/reference/core.rst index 0aa00c69..3d8c128c 100644 --- a/docs/source/reference/core.rst +++ b/docs/source/reference/core.rst @@ -20,3 +20,10 @@ ------------------------------------------ .. autoclass:: clickgen.core.CursorAlias .. automethod:: clickgen.core.CursorAlias.__init__ +.. automethod:: clickgen.core.CursorAlias.from_bitmap +.. automethod:: clickgen.core.CursorAlias.create +.. automethod:: clickgen.core.CursorAlias.check_alias +.. automethod:: clickgen.core.CursorAlias.extension +.. automethod:: clickgen.core.CursorAlias.copy +.. automethod:: clickgen.core.CursorAlias.rename +.. automethod:: clickgen.core.CursorAlias.reproduce From 82e3b2e4b308b07798673473806e9c6fb6b8466d Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Fri, 19 Mar 2021 19:07:59 +0530 Subject: [PATCH 42/53] =?UTF-8?q?=F0=9F=94=A5Configure=20upcoming=20versio?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 3c32ee43..d1a9bb02 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -23,7 +23,7 @@ author = "Kaiz Khatri" # The full version, including alpha/beta/rc tags -release = "1.2.0" +release = "1.1.9" # -- General configuration --------------------------------------------------- From 69ccd5c0cdec66db3fc74f83ab8bd2eb2de5808b Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Fri, 19 Mar 2021 19:12:08 +0530 Subject: [PATCH 43/53] =?UTF-8?q?=F0=9F=93=9D=20Changeslogs=20&=20docs=20b?= =?UTF-8?q?adge=20in=20readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ README.md | 1 + 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e1ba592..675a156b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bitmap and CursorsAlias memember access outside the context manager - `make` command error raise in `setup.py` - Better typing experience +- Configure readthedocs with `sphinx` +- Added **docs** badge ### Changed diff --git a/README.md b/README.md index 2666d1b5..0ff69bd2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![CI](https://github.com/ful1e5/clickgen/workflows/CI/badge.svg)](https://github.com/ful1e5/clickgen/actions) [![PyPI - Wheel](https://img.shields.io/pypi/wheel/pytype)](https://pypi.org/project/clickgen/#files) +[![Docs](https://readthedocs.org/projects/clickgen/badge/?version=latest)](https://clickgen.readthedocs.io/en/latest/) [![Code Coverage](https://codecov.io/gh/ful1e5/clickgen/branch/main/graph/badge.svg)](https://codecov.io/gh/ful1e5/clickgen) [![CodeFactor](https://www.codefactor.io/repository/github/ful1e5/clickgen/badge/main)](https://www.codefactor.io/repository/github/ful1e5/clickgen/overview/main) From f6c6040a3b261ee7ad61ed79066f9bc5ccac22d8 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 20 Mar 2021 17:07:08 +0530 Subject: [PATCH 44/53] =?UTF-8?q?=F0=9F=94=A7=20fix=20Pillow=20vulnerabili?= =?UTF-8?q?ties=20&=20rtd=20requirements=20updated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/requirements.txt | 7 ++++--- readthedocs.yml | 2 +- setup.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 707e9f5e..dbbb0577 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,3 +1,4 @@ -Pillow -sphinx-rtd-theme - +Pillow>=8.1.1 +sphinx-rtd-theme==0.5.1 +readthedocs-sphinx-search==0.1.0 +sphinx-autoapi==1.7.0 diff --git a/readthedocs.yml b/readthedocs.yml index fd303691..47267245 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -15,6 +15,6 @@ formats: # Optionally set the version of Python and requirements required to build your docs python: - version: 3.7 + version: 3.8 install: - requirements: docs/requirements.txt diff --git a/setup.py b/setup.py index 5c8e95f2..2c83c828 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ def run(self): "Funding": "https://www.paypal.me/kaizkhatri", "Changelog": "https://github.com/ful1e5/clickgen/blob/main/CHANGELOG.md", }, - install_requires=["Pillow>=7.2.0"], + install_requires=["Pillow>=8.1.1"], packages=["clickgen"], package_dir={"clickgen": "clickgen"}, classifiers=[ From 9b78cad8b8d634c4b2b7d6fad105d43fd4179071 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 20 Mar 2021 17:17:43 +0530 Subject: [PATCH 45/53] =?UTF-8?q?=F0=9F=93=A6=20Pip=20install=20in=20readt?= =?UTF-8?q?hedocs=20console?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readthedocs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs.yml b/readthedocs.yml index 47267245..d3661ac6 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -15,6 +15,6 @@ formats: # Optionally set the version of Python and requirements required to build your docs python: - version: 3.8 + pip_install: true install: - requirements: docs/requirements.txt From 5e81c1bf8d7f9c912701cb0f665e5c5e7b4144cb Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 20 Mar 2021 17:20:34 +0530 Subject: [PATCH 46/53] =?UTF-8?q?=F0=9F=93=9A=20Docs=20build=20setting=20u?= =?UTF-8?q?pdated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readthedocs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/readthedocs.yml b/readthedocs.yml index d3661ac6..f58d6f93 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -16,5 +16,6 @@ formats: # Optionally set the version of Python and requirements required to build your docs python: pip_install: true + version: 3.8 install: - requirements: docs/requirements.txt From 2c86d691834f3d00ecd24ef750761eccb95eed7c Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 20 Mar 2021 17:34:13 +0530 Subject: [PATCH 47/53] =?UTF-8?q?=F0=9F=94=97=20Requirements=20updated?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/requirements.txt | 1 - readthedocs.yml | 3 ++- requirements.txt | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index dbbb0577..f3e42287 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,3 @@ -Pillow>=8.1.1 sphinx-rtd-theme==0.5.1 readthedocs-sphinx-search==0.1.0 sphinx-autoapi==1.7.0 diff --git a/readthedocs.yml b/readthedocs.yml index f58d6f93..f6c8eb53 100644 --- a/readthedocs.yml +++ b/readthedocs.yml @@ -15,7 +15,8 @@ formats: # Optionally set the version of Python and requirements required to build your docs python: - pip_install: true version: 3.8 install: - requirements: docs/requirements.txt + - method: setuptools + path: . diff --git a/requirements.txt b/requirements.txt index 064a6fd6..27f53165 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -Pillow>=7.2.0 \ No newline at end of file +# Only used in docker image +Pillow>=8.1.1 From 6c9abd434d75c44f1bcad9afdbc95b394e8647e9 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 20 Mar 2021 17:46:51 +0530 Subject: [PATCH 48/53] =?UTF-8?q?=E2=84=B9=EF=B8=8F=20autodoc.api=20packag?= =?UTF-8?q?e=20path=20fixed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/conf.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index d1a9bb02..d223c068 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -13,8 +13,7 @@ import os import sys -sys.path.insert(0, os.path.abspath("../../clickgen")) - +sys.path.insert(0, os.path.abspath("./../..")) # -- Project information ----------------------------------------------------- From 7cd458b0a2f19b320c34fac00710b534591fd171 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 20 Mar 2021 17:56:07 +0530 Subject: [PATCH 49/53] =?UTF-8?q?=F0=9F=93=A6=F0=9F=92=BE=20cahching=20key?= =?UTF-8?q?=20set=20to=20"setup.py"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/app-ci.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/app-ci.yml b/.github/workflows/app-ci.yml index 46d71100..a60df8d2 100644 --- a/.github/workflows/app-ci.yml +++ b/.github/workflows/app-ci.yml @@ -1,13 +1,13 @@ name: CI on: + paths-ignore: + - README.md + - LICENSE push: - paths-ignore: - - README.md - - LICENSE - branches: - - main - - dev + branches: + - main + - dev pull_request: paths-ignore: @@ -69,16 +69,14 @@ jobs: run: sudo apt install libx11-dev libxcursor-dev libpng-dev continue-on-error: false - - name: Cache pip dependencies + - name: Caching pip packages uses: actions/cache@v2 + id: pip-cache # use this to check for `cache-hit` (`steps.pip-cache.outputs.cache-hit != 'true'`) with: - # This path is specific to Ubuntu path: ~/.cache/pip - # Look to see if there is a cache hit for the corresponding requirements file - key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} restore-keys: | ${{ runner.os }}-pip- - ${{ runner.os }}- - name: Install pip dependencies run: | From efe3965aa54b462df512858e2c19ec930ca1a116 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sat, 20 Mar 2021 17:58:48 +0530 Subject: [PATCH 50/53] =?UTF-8?q?=F0=9F=92=9D=20Format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/app-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/app-ci.yml b/.github/workflows/app-ci.yml index a60df8d2..fdf9afa7 100644 --- a/.github/workflows/app-ci.yml +++ b/.github/workflows/app-ci.yml @@ -1,13 +1,13 @@ name: CI on: - paths-ignore: - - README.md - - LICENSE push: - branches: - - main - - dev + paths-ignore: + - README.md + - LICENSE + branches: + - main + - dev pull_request: paths-ignore: From c9d2ec22bffe9f721ac24ac5f721bc732ef39510 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sun, 21 Mar 2021 17:42:44 +0530 Subject: [PATCH 51/53] =?UTF-8?q?=F0=9F=93=83=20Changes=20logs=20for=20v1.?= =?UTF-8?q?1.9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/dependabot.yml | 12 ++++++------ CHANGELOG.md | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index f4952bab..f4020074 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,8 +1,8 @@ version: 2 updates: -- package-ecosystem: pip - directory: "/" - schedule: - interval: daily - time: "10:00" - open-pull-requests-limit: 10 + - package-ecosystem: pip + directory: "/" + schedule: + interval: daily + time: "10:00" + open-pull-requests-limit: 10 diff --git a/CHANGELOG.md b/CHANGELOG.md index 675a156b..9a696fae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,14 +10,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Couple of **linting** problem fixes -- Bitmap and CursorsAlias memember access outside the context manager -- `make` command error raise in `setup.py` +- **Bitmap** and **CursorsAlias** memember access outside the context manager +- Check `make` command in `setup.py` - Better typing experience - Configure readthedocs with `sphinx` -- Added **docs** badge +- Added **docs** badge in `README.md` ### Changed +- Fixed Pillow vulnerabilities by bumped it to `8.1.1` +- python caching updated in `app-ci.yml` - `Literal` typing removed from `clickgen.util` & `clickgen.core` - Fixed #23 packaging issue of `XPackager` - Fixed #22 Inside `util.PNGProvider` From 758410d774e7597c24a753a053169a4932a0cc82 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Sun, 21 Mar 2021 17:52:51 +0530 Subject: [PATCH 52/53] =?UTF-8?q?=E2=84=B9=EF=B8=8F=20=20clickgen=201.1.9?= =?UTF-8?q?=20python=20version=20supports?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/source/installation.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 6d48db23..b03c1fc0 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -18,6 +18,8 @@ clickgen supports these Python versions. +---------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ | **Python** | **3.9** | **3.8** | **3.7** | **3.6** | **3.5** | **3.4** | **3.3** | **3.2** | **2.7** | **2.6** | **2.5** | **2.4** | +=====================+=========+=========+=========+=========+=========+=========+=========+=========+=========+=========+=========+=========+ +| clickgen 1.1.9 | Yes | Yes | | | | | | | | | | | ++---------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ | clickgen 1.1.8 | Yes | Yes | | | | | | | | | | | +---------------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+ | clickgen 1.1.7 | Yes | Yes | Yes | Yes | | | | | | | | | From 1cdabe99651e36b94f0f98394ee16df5be731689 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Mon, 22 Mar 2021 14:58:00 +0530 Subject: [PATCH 53/53] =?UTF-8?q?=F0=9F=9A=80=20Prepare=20v1.1.9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 11 +++++++---- setup.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a696fae..21c43759 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +## [1.1.9] - 22 Mar 2021 + ### Added - Couple of **linting** problem fixes @@ -24,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed #23 packaging issue of `XPackager` - Fixed #22 Inside `util.PNGProvider` -## [1.1.8] - 24 jan 2021 (Stable) +## [1.1.8] - 24 Jan 2021 ### Added @@ -44,7 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - GitHub workflow with `matrix` - fixed #12 -## [1.1.7] - 5 Oct 2020 (Stable) +## [1.1.7] - 5 Oct 2020 ### Added @@ -56,7 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - skip `Pillow` is already installed -## [1.1.6] - 24 Sept 2020 (Stable) +## [1.1.6] - 24 Sept 2020 ### Changed @@ -130,7 +132,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - auto-generated **symlinks** based on input configs - `.tar` archive & `directory` as out **package**. -[unreleased]: https://github.com/ful1e5/clickgen/compare/v1.1.8...main +[unreleased]: https://github.com/ful1e5/clickgen/compare/v1.1.9...main +[1.1.9]: https://github.com/ful1e5/clickgen/compare/v1.1.8...v1.1.9 [1.1.8]: https://github.com/ful1e5/clickgen/compare/v1.1.7...v1.1.8 [1.1.7]: https://github.com/ful1e5/clickgen/compare/1.1.6...v1.1.7 [1.1.6]: https://github.com/ful1e5/clickgen/compare/1.1.5-beta...1.1.6 diff --git a/setup.py b/setup.py index 2c83c828..968b65d6 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ def run(self): setup( name="clickgen", - version="1.1.8", + version="1.1.9", author="Kaiz Khatri", author_email="kaizmandhu@gmail.com", description="The hassle-free cursor building toolbox 🧰",