From f819ff2e009d4cfcad85d45c59e4df8d90700885 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+ful1e5@users.noreply.github.com> Date: Thu, 18 Feb 2021 19:10:54 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=94=20Old=20builder=20package=20remove?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Builder is responsible for building the cursors from png files, That's stored in /bitmaps' directory. As clickgen(v1.1.8) is build cursors individually, Bibata builder need to be improved. --- build.py | 71 ------------------------------- builder/__init__.py | 6 --- builder/bundler.py | 80 ---------------------------------- builder/config.py | 54 ----------------------- builder/cursor.py | 64 ---------------------------- builder/hotspots.json | 99 ------------------------------------------- builder/log.py | 11 ----- builder/pkg_info.py | 13 ------ builder/windows.inf | 52 ----------------------- setup.py | 23 ---------- 10 files changed, 473 deletions(-) delete mode 100644 build.py delete mode 100644 builder/__init__.py delete mode 100644 builder/bundler.py delete mode 100644 builder/config.py delete mode 100644 builder/cursor.py delete mode 100644 builder/hotspots.json delete mode 100644 builder/log.py delete mode 100644 builder/pkg_info.py delete mode 100644 builder/windows.inf delete mode 100644 setup.py diff --git a/build.py b/build.py deleted file mode 100644 index 72607c19..00000000 --- a/build.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import sys -import argparse -from argparse import ArgumentParser -from os import path, listdir -from typing import List - -from builder.pkg_info import info -from builder.config import ConfigProvider -from builder.cursor import CursorBuilder - - -def get_args_parser() -> ArgumentParser: - """Parse command line arguments""" - parser = argparse.ArgumentParser(description=info["description"]) - - parser.add_argument( - "-x", - "--x11", - action="store_true", - default=False, - help=("Bundle X11 cursors from bitmaps" " (default: %(default)s)"), - ) - - parser.add_argument( - "-w", - "--windows", - action="store_true", - default=False, - help=("Bundle Windows cursors from bitmaps" " (default: %(default)s)"), - ) - - return parser - - -def build() -> None: - """ Build Bibata cursor """ - parser = get_args_parser() - try: - args = parser.parse_args() - except Exception: - sys.exit(0) - - bitmaps_dir = "./bitmaps" - out_dir = "./themes" - - # print builder information - print(info["description"]) - - bitmaps_dirs = listdir(bitmaps_dir) - configs: List[ConfigProvider] = [] - builders: List[CursorBuilder] = [] - - for index, name in enumerate(bitmaps_dirs): - theme_bitmaps_dir = path.join(bitmaps_dir, name) - configs.append(ConfigProvider(name, theme_bitmaps_dir, out_dir)) - builders.append(CursorBuilder(configs[index])) - - for builder in builders: - if args.x11 == args.windows: - builder.build_cursors() - elif args.x11: - builder.build_x11_cursors() - elif args.windows: - builder.build_win_cursors() - - -if __name__ == "__main__": - build() diff --git a/builder/__init__.py b/builder/__init__.py deleted file mode 100644 index f29c6b82..00000000 --- a/builder/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from .log import save_logs_to_file - -save_logs_to_file() diff --git a/builder/bundler.py b/builder/bundler.py deleted file mode 100644 index f12ec7de..00000000 --- a/builder/bundler.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import shutil -from os import listdir, path, remove, rename - -from .config import ConfigProvider - -# Windows Cursors Config -windows_cursors = { - "left_ptr_watch.ani": "AppStarting.ani", - "left_ptr.cur": "Arrow.cur", - "crosshair.cur": "Cross.cur", - "hand2.cur": "Hand.cur", - "pencil.cur": "Handwriting.cur", - "dnd-ask.cur": "Help.cur", - "xterm.cur": "IBeam.cur", - "circle.cur": "NO.cur", - "all-scroll.cur": "SizeAll.cur", - "bd_double_arrow.cur": "SizeNWSE.cur", - "sb_v_double_arrow.cur": "SizeNS.cur", - "fd_double_arrow.cur": "SizeNESW.cur", - "sb_h_double_arrow.cur": "SizeWE.cur", - "right_ptr.cur": "Alternate.cur", - "wait.ani": "Wait.ani", -} - - -class Bundler: - """ - Create crisp package for Bibata Windows & X11 packages 📦. - """ - - def __init__(self, config: ConfigProvider) -> None: - self.__name = config.name - self.__tmpdir = config.tmpdir - self.__x11_dest = path.join(config.out_dir, self.__name) - self.__win_dest = path.join(config.out_dir, self.__name + "-Windows") - self.__content = config.get_windows_script() - - def __save_win_install_script(self) -> None: - """ Save `install.inf` file in windows cursor theme. """ - file_path = path.join(self.__win_dest, "install.inf") - with open(file_path, "w") as file: - file.write(self.__content) - - def __clean_win_bundle(self) -> None: - """ Remvoe unnecessary cursor from directory generated by `clickgen` """ - # Remove & Rename cursors - # If Key found => Rename else Remove - for cursor in listdir(self.__win_dest): - old_path = path.join(self.__win_dest, cursor) - - try: - new_path = path.join(self.__win_dest, windows_cursors[cursor]) - rename(old_path, new_path) - except KeyError: - remove(old_path) - - self.__save_win_install_script() - - def win_bundle(self) -> None: - """ Make cursor theme installable on `Windows OS`. """ - src = path.join(self.__tmpdir, self.__name, "win") - shutil.copytree(src, self.__win_dest) - self.__clean_win_bundle() - - def x11_bundle(self) -> None: - """ Make cursor theme installable on `x11`. """ - src = path.join(self.__tmpdir, self.__name, "x11") - shutil.copytree(src, self.__x11_dest, symlinks=True) - - def bundle(self) -> None: - """ Make cursor theme installable on `x11` & `Windows OS`. """ - x11_src = path.join(self.__tmpdir, self.__name, "x11") - shutil.copytree(x11_src, self.__x11_dest, symlinks=True) - - win_src = path.join(self.__tmpdir, self.__name, "win") - shutil.copytree(win_src, self.__win_dest) - self.__clean_win_bundle() diff --git a/builder/config.py b/builder/config.py deleted file mode 100644 index 7f95ab41..00000000 --- a/builder/config.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import json -import shutil -import sys -import tempfile -from os import mkdir, path - -from . import __path__ -from .pkg_info import info - -# Build Config -delay = 35 -sizes = [22, 24, 28, 32, 40, 48, 56, 64, 72, 80, 88, 96] - -# read hotspots file -with open(path.join(__path__[0], "hotspots.json")) as hotspot_file: - hotspots = json.loads(hotspot_file.read()) - - -class ConfigProvider: - """ - Configure `Bibata` building process 🔧. - """ - - def __init__(self, name: str, bitmaps_dir: str, out_dir: str) -> None: - # cleanup old packages - if path.exists(out_dir): - shutil.rmtree(out_dir) - - mkdir(out_dir) - - # Checking Bitmaps directory - if not path.exists(bitmaps_dir): - print( - "⚠ BITMAPS NOT FOUND.\n\n`yarn install && yarn render` to Generates Bitmaps" - ) - sys.exit(1) - - self.name: str = name - self.bitmaps_dir: str = path.abspath(bitmaps_dir) - self.tmpdir: str = tempfile.mkdtemp() - self.out_dir: str = path.abspath(out_dir) - - def get_windows_script(self) -> str: - """ Get `install.inf` content for this cursor theme. """ - with open(path.join(__path__[0], "windows.inf")) as f: - data = f.read() - inf_content = data.replace( - "", self.name + " Cursors" - ).replace("", info["author"]) - - return inf_content diff --git a/builder/cursor.py b/builder/cursor.py deleted file mode 100644 index bee1d0c1..00000000 --- a/builder/cursor.py +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from clickgen import build_cursor_theme, build_win_cursor_theme, build_x11_cursor_theme - -from .bundler import Bundler -from .config import ConfigProvider, delay, hotspots, sizes - - -class CursorBuilder: - """ - Build Bibata Windows & X11 cursors 🚀. - """ - - def __init__(self, config: ConfigProvider) -> None: - self.__name = config.name - self.__bitmaps_dir = config.bitmaps_dir - self.__bundler = Bundler(config) - self.__tmpdir = config.tmpdir - - def build_x11_cursors(self) -> None: - """ Build `x11` platform cursors. """ - print("🌈 Building %s Theme ..." % self.__name) - build_x11_cursor_theme( - name=self.__name, - image_dir=self.__bitmaps_dir, - cursor_sizes=sizes, - hotspots=hotspots, - out_path=self.__tmpdir, - archive=False, - delay=delay, - ) - - self.__bundler.x11_bundle() - - def build_win_cursors(self) -> None: - """ Build `Windows` platform cursors. """ - print("🌈 Building %s Theme ..." % self.__name) - build_win_cursor_theme( - name=self.__name, - image_dir=self.__bitmaps_dir, - cursor_sizes=sizes, - hotspots=hotspots, - out_path=self.__tmpdir, - archive=False, - delay=delay, - ) - - self.__bundler.win_bundle() - - def build_cursors(self) -> None: - """ Build `x11` & `Windows` platform cursors. """ - print("🌈 Building %s Theme ..." % self.__name) - build_cursor_theme( - name=self.__name, - image_dir=self.__bitmaps_dir, - cursor_sizes=sizes, - hotspots=hotspots, - out_path=self.__tmpdir, - archive=False, - delay=delay, - ) - - self.__bundler.bundle() diff --git a/builder/hotspots.json b/builder/hotspots.json deleted file mode 100644 index 2271367a..00000000 --- a/builder/hotspots.json +++ /dev/null @@ -1,99 +0,0 @@ -{ - "all_scroll": { "xhot": 100, "yhot": 100 }, - "dotbox": { "xhot": 100, "yhot": 100 }, - "move": { "xhot": 100, "yhot": 100 }, - "plus": { "xhot": 100, "yhot": 100 }, - "vertical_text": { "xhot": 100, "yhot": 100 }, - "wait": { "xhot": 100, "yhot": 100 }, - "wayland_cursor": { "xhot": 100, "yhot": 100 }, - "x_cursor": { "xhot": 100, "yhot": 100 }, - "xterm": { "xhot": 100, "yhot": 100 }, - - "bd_double_arrow": { "xhot": 98, "yhot": 100 }, - "fd_double_arrow": { "xhot": 98, "yhot": 100 }, - - "bottom_left_corner": { "xhot": 31, "yhot": 172 }, - "bottom_right_corner": { "xhot": 170, "yhot": 172 }, - - "bottom_side": { "xhot": 100, "yhot": 164 }, - "bottom_tee": { "xhot": 100, "yhot": 164 }, - - "center_ptr": { "xhot": 98, "yhot": 131 }, - - "circle": { "xhot": 48, "yhot": 25 }, - "context_menu": { "xhot": 48, "yhot": 25 }, - "copy": { "xhot": 48, "yhot": 25 }, - "link": { "xhot": 48, "yhot": 25 }, - "pointer_move": { "xhot": 48, "yhot": 25 }, - - "cross": { "xhot": 98, "yhot": 96 }, - - "crossed_circle": { "xhot": 100, "yhot": 100 }, - - "crosshair": { "xhot": 99, "yhot": 99 }, - - "dnd_ask": { "xhot": 86, "yhot": 79 }, - "dnd_copy": { "xhot": 86, "yhot": 79 }, - "dnd_link": { "xhot": 86, "yhot": 79 }, - "dnd_move": { "xhot": 86, "yhot": 79 }, - "dnd_no_drop": { "xhot": 86, "yhot": 79 }, - - "dnd_none": { "xhot": 99, "yhot": 98 }, - - "grabbing": { "xhot": 106, "yhot": 79 }, - - "hand1": { "xhot": 113, "yhot": 95 }, - - "hand2": { "xhot": 88, "yhot": 32 }, - - "left_ptr_watch": { "xhot": 50, "yhot": 28 }, - - "left_ptr": { "xhot": 53, "yhot": 36 }, - - "left_side": { "xhot": 35, "yhot": 100 }, - - "left_tee": { "xhot": 165, "yhot": 95 }, - - "ll_angle": { "xhot": 34, "yhot": 165 }, - - "lr_angle": { "xhot": 167, "yhot": 164 }, - - "pencil": { "xhot": 37, "yhot": 161 }, - - "question_arrow": { "xhot": 102, "yhot": 102 }, - - "right_ptr": { "xhot": 150, "yhot": 29 }, - - "right_side": { "xhot": 163, "yhot": 98 }, - - "right_tee": { "xhot": 30, "yhot": 96 }, - - "sb_down_arrow": { "xhot": 100, "yhot": 126 }, - - "sb_h_double_arrow": { "xhot": 100, "yhot": 100 }, - "sb_v_double_arrow": { "xhot": 100, "yhot": 100 }, - - "sb_left_arrow": { "xhot": 86, "yhot": 100 }, - - "sb_right_arrow": { "xhot": 113, "yhot": 100 }, - - "sb_up_arrow": { "xhot": 99, "yhot": 86 }, - - "tcross": { "xhot": 98, "yhot": 100 }, - - "top_left_corner": { "xhot": 29, "yhot": 27 }, - - "top_right_corner": { "xhot": 170, "yhot": 28 }, - - "top_side": { "xhot": 98, "yhot": 34 }, - - "top_tee": { "xhot": 98, "yhot": 29 }, - - "ul_angle": { "xhot": 34, "yhot": 35 }, - - "ur_angle": { "xhot": 164, "yhot": 34 }, - - "zoom_in": { "xhot": 90, "yhot": 89 }, - - "zoom_out": { "xhot": 93, "yhot": 90 } -} diff --git a/builder/log.py b/builder/log.py deleted file mode 100644 index 84c4f7ac..00000000 --- a/builder/log.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import logging -import os - - -def save_logs_to_file() -> None: - """ Save `clickgen` logs to `build.log` in current working directory. """ - logging.basicConfig(filename='%s/build.log' % os.getcwd(), filemode='w', - format='%(name)s - %(levelname)s - %(message)s', level=logging.DEBUG) diff --git a/builder/pkg_info.py b/builder/pkg_info.py deleted file mode 100644 index e48cd86c..00000000 --- a/builder/pkg_info.py +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -__version__ = "1.0.3" - -info = { - "pkg_name": "builder", - "version": __version__, - "author": "Kaiz Khatri", - "description": f"⚡ Bibata Builder - v{__version__}", - "email": "kaizmandhu@gmail.com", - "url": "https://github.com/ful1e5/Bibata_Cursor/", -} \ No newline at end of file diff --git a/builder/windows.inf b/builder/windows.inf deleted file mode 100644 index c9e11562..00000000 --- a/builder/windows.inf +++ /dev/null @@ -1,52 +0,0 @@ -[Version] -signature="$CHICAGO$" - By Kaiz Khatri -https://github.com/ful1e5/Bibata_Cursor - -[DefaultInstall] -CopyFiles = Scheme.Cur -AddReg = Scheme.Reg - -[DestinationDirs] -Scheme.Cur = 10,"%CUR_DIR%" - -[Scheme.Reg] -HKCU,"Control Panel\Cursors\Schemes","%SCHEME_NAME%",,"%10%\%CUR_DIR%\%pointer%,%10%\%CUR_DIR%\%help%,%10%\%CUR_DIR%\%work%,%10%\%CUR_DIR%\%busy%,%10%\%CUR_DIR%\%Cross%,%10%\%CUR_DIR%\%Text%,%10%\%CUR_DIR%\%Hand%,%10%\%CUR_DIR%\%Unavailiable%,%10%\%CUR_DIR%\%Vert%,%10%\%CUR_DIR%\%Horz%,%10%\%CUR_DIR%\%Dgn1%,%10%\%CUR_DIR%\%Dgn2%,%10%\%CUR_DIR%\%move%,%10%\%CUR_DIR%\%alternate%,%10%\%CUR_DIR%\%link%" - -; -- Installed files - -[Scheme.Cur] -"Arrow.cur" -"Help.cur" -"AppStarting.ani" -"Wait.ani" -"Cross.cur" -"IBeam.cur" -"Handwriting.cur" -"NO.cur" -"SizeNS.cur" -"SizeWE.cur" -"SizeNWSE.cur" -"SizeNESW.cur" -"SizeAll.cur" -"Alternate.cur" -"Hand.cur" - -[Strings] -CUR_DIR = "Cursors\" -SCHEME_NAME = "" -pointer = "Arrow.cur" -help = "Help.cur" -work = "AppStarting.ani" -busy = "Wait.ani" -cross = "Cross.cur" -text = "IBeam.cur" -hand = "Handwriting.cur" -unavailiable = "NO.cur" -vert = "SizeNS.cur" -horz = "SizeWE.cur" -dgn1 = "SizeNWSE.cur" -dgn2 = "SizeNESW.cur" -move = "SizeAll.cur" -alternate = "Alternate.cur" -link = "Hand.cur" \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index aa02c378..00000000 --- a/setup.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from builder.pkg_info import info -from setuptools import setup, find_namespace_packages - -setup( - name=info["pkg_name"], - version=info["version"], - description=info["description"], - url=info["url"], - author=info["author"], - author_email=info["email"], - install_requires=["Pillow>=7.2.0", "clickgen==1.1.7"], - packages=find_namespace_packages(include=["builder"]), - classifiers=[ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", - ], - python_requires=">=3.6", - include_package_data=True, - zip_safe=False, -)