Bibata_Cursor/builder/config.py

55 lines
1.5 KiB
Python
Raw Normal View History

2020-10-08 01:34:47 -04:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
2020-10-08 02:29:27 -04:00
import sys
2020-10-08 03:04:19 -04:00
import json
2020-10-08 01:34:47 -04:00
import shutil
2020-10-09 07:50:21 -04:00
from os import path, mkdir
2020-10-10 07:50:01 -04:00
import tempfile
2020-10-09 03:17:13 -04:00
2020-10-24 00:33:29 -04:00
from . import __path__
from .pkg_info import info
2020-10-09 03:17:13 -04:00
# 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())
2020-10-08 01:34:47 -04:00
2020-10-14 23:20:27 -04:00
class ConfigProvider:
2020-10-08 01:34:47 -04:00
"""
2020-10-14 23:20:27 -04:00
Configure `Bibata` building process 🔧.
2020-10-08 01:34:47 -04:00
"""
2020-10-10 07:50:01 -04:00
def __init__(self, name: str, bitmaps_dir: str, out_dir: str) -> None:
2020-10-08 02:29:27 -04:00
# cleanup old packages
if path.exists(out_dir):
2020-10-08 01:34:47 -04:00
shutil.rmtree(out_dir)
2020-10-09 07:50:21 -04:00
mkdir(out_dir)
2020-10-09 03:17:13 -04:00
2020-10-08 02:29:27 -04:00
# Checking Bitmaps directory
if not path.exists(bitmaps_dir):
print(
2020-10-14 23:20:27 -04:00
"⚠ BITMAPS NOT FOUND.\n\n`yarn install && yarn render` to Generates Bitmaps"
)
2020-10-08 02:29:27 -04:00
sys.exit(1)
2020-10-10 07:50:01 -04:00
self.name: str = name
2020-10-09 07:50:21 -04:00
self.bitmaps_dir: str = path.abspath(bitmaps_dir)
2020-10-10 07:50:01 -04:00
self.tmpdir: str = tempfile.mkdtemp()
2020-10-09 07:50:21 -04:00
self.out_dir: str = path.abspath(out_dir)
2020-10-08 02:29:27 -04:00
2020-10-10 07:50:01 -04:00
def get_windows_script(self) -> str:
2020-10-14 22:55:11 -04:00
""" Get `install.inf` content for this cursor theme. """
2020-10-09 03:17:13 -04:00
with open(path.join(__path__[0], "windows.inf")) as f:
2020-10-08 01:34:47 -04:00
data = f.read()
inf_content = data.replace(
2020-10-14 23:20:27 -04:00
"<inject_theme_name>", self.name + " Cursors"
).replace("<inject_author_name>", info["author"])
2020-10-08 01:34:47 -04:00
return inf_content