Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packaging #98

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "yasb"
version = "0.0.1"
dependencies = [
"BlurWindow==1.2.1",
"Cerberus==1.3.4",
"cssutils==2.5.1",
"humanize==4.3.0",
"psutil==5.9.1",
"PyQt6==6.3.1",
"pytz==2022.1",
"pywin32==304",
"PyYAML==6.0",
"tzlocal==4.2",
"watchdog==2.1.9",
"winsdk==1.0.0b6",
]
[project.scripts]
yasb = "yasb:main.main"
Empty file added src/yasb/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions src/yasb/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import main

if __name__ == '__main__':
main.main(log=True)
File renamed without changes.
File renamed without changes.
Empty file added src/yasb/core/__init__.py
Empty file.
6 changes: 3 additions & 3 deletions src/core/bar.py → src/yasb/core/bar.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging
from settings import APP_BAR_TITLE
from ..settings import APP_BAR_TITLE
from PyQt6.QtWidgets import QApplication, QWidget, QHBoxLayout, QGridLayout, QFrame
from PyQt6.QtGui import QScreen
from PyQt6.QtCore import Qt, QRect
from core.utils.utilities import is_valid_percentage_str, percent_to_float
from core.validation.bar import BAR_DEFAULTS
from .utils.utilities import is_valid_percentage_str, percent_to_float
from .validation.bar import BAR_DEFAULTS
from BlurWindow.blurWindow import GlobalBlur

try:
Expand Down
10 changes: 5 additions & 5 deletions src/core/bar_manager.py → src/yasb/core/bar_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from PyQt6.QtWidgets import QApplication
from PyQt6.QtGui import QScreen
from PyQt6.QtCore import QObject, pyqtSignal, pyqtSlot
from core.bar import Bar
from core.utils.widget_builder import WidgetBuilder
from core.utils.utilities import get_screen_by_name
from core.event_service import EventService
from core.config import get_stylesheet, get_config
from .bar import Bar
from .utils.widget_builder import WidgetBuilder
from .utils.utilities import get_screen_by_name
from .event_service import EventService
from .config import get_stylesheet, get_config
from copy import deepcopy


Expand Down
6 changes: 3 additions & 3 deletions src/core/config.py → src/yasb/core/config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import logging
import settings
from .. import settings
from os import path
from sys import argv, exit
from pathlib import Path
from typing import Union
from core.validation.config import CONFIG_SCHEMA
from core.utils.alert_dialog import raise_info_alert
from .validation.config import CONFIG_SCHEMA
from .utils.alert_dialog import raise_info_alert
from cssutils import CSSParser
from cerberus import Validator, schema
from yaml.parser import ParserError
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from PyQt6.QtCore import QObject, pyqtSignal
from typing import Any
from core.event_enums import Event
from .event_enums import Event


@functools.lru_cache()
Expand Down
4 changes: 2 additions & 2 deletions src/core/log.py → src/yasb/core/log.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from os.path import join
from settings import DEFAULT_LOG_FILENAME, APP_NAME, APP_NAME_FULL
from core.config import get_config_dir
from ..settings import DEFAULT_LOG_FILENAME, APP_NAME, APP_NAME_FULL
from .config import get_config_dir

LOG_PATH = join(get_config_dir(), DEFAULT_LOG_FILENAME)
LOG_FORMAT = "%(asctime)s %(levelname)s %(filename)s: %(message)s"
Expand Down
4 changes: 2 additions & 2 deletions src/core/tray.py → src/yasb/core/tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from PyQt6.QtWidgets import QSystemTrayIcon, QMenu
from PyQt6.QtGui import QIcon
from PyQt6.QtCore import QCoreApplication, QSize
from core.bar_manager import BarManager
from settings import GITHUB_URL, FAVICON_PATH, APP_NAME, APP_NAME_FULL
from .bar_manager import BarManager
from ..settings import GITHUB_URL, FAVICON_PATH, APP_NAME, APP_NAME_FULL


class TrayIcon(QSystemTrayIcon):
Expand Down
Empty file added src/yasb/core/utils/__init__.py
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import traceback
from settings import APP_NAME
from ...settings import APP_NAME
from PyQt6.QtWidgets import QMessageBox, QTextEdit, QSizePolicy
from PyQt6.QtCore import Qt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import win32pipe
import win32file
from PyQt6.QtCore import QThread
from core.event_enums import KomorebiEvent
from core.event_service import EventService
from core.utils.komorebi.client import KomorebiClient
from ...event_enums import KomorebiEvent
from ...event_service import EventService
from .client import KomorebiClient

KOMOREBI_PIPE_BUFF_SIZE = 64 * 1024
KOMOREBI_PIPE_NAME = "yasb"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from typing import Optional
from cerberus import Validator
from importlib import import_module
from core.utils.alert_dialog import raise_info_alert
from settings import DEFAULT_CONFIG_FILENAME
from .alert_dialog import raise_info_alert
from ...settings import DEFAULT_CONFIG_FILENAME


class WidgetBuilder(QObject):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging
from PyQt6.QtWidgets import QWidget, QFrame
from PyQt6.QtCore import pyqtSignal, Qt
from core.event_service import EventService
from core.utils.win32.windows import WinEvent
from core.bar import BAR_WM_TITLE
from core.utils.win32.utilities import get_hwnd_info, get_window_extended_frame_bounds, is_window_maximised
from ...event_service import EventService
from .windows import WinEvent
from ...bar import BAR_WM_TITLE
from .utilities import get_hwnd_info, get_window_extended_frame_bounds, is_window_maximised

IGNORED_CLASSES = [
'WorkerW',
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import logging
from PyQt6.QtCore import QThread
from win32gui import GetForegroundWindow
from core.utils.win32.windows import WinEventProcType, WinEvent, user32, ole32, msg
from core.event_service import EventService
from .windows import WinEventProcType, WinEvent, user32, ole32, msg
from ...event_service import EventService


class SystemEventListener(QThread):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ctypes.wintypes
from core.event_enums import Event
from ...event_enums import Event

user32 = ctypes.windll.user32
user32.SetWinEventHook.restype = ctypes.wintypes.HANDLE
Expand Down
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from core.validation.bar import BAR_SCHEMA, BAR_DEFAULTS
from .bar import BAR_SCHEMA, BAR_DEFAULTS

CONFIG_SCHEMA = {
'watch_config': {
Expand Down
6 changes: 3 additions & 3 deletions src/core/watcher.py → src/yasb/core/watcher.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import logging
from os.path import basename
from core.config import get_config_dir
from settings import DEFAULT_STYLES_FILENAME, DEFAULT_CONFIG_FILENAME
from .config import get_config_dir
from ..settings import DEFAULT_STYLES_FILENAME, DEFAULT_CONFIG_FILENAME
from watchdog.observers import Observer
from watchdog.events import PatternMatchingEventHandler, FileModifiedEvent
from core.bar_manager import BarManager
from .bar_manager import BarManager


class FileModifiedEventHandler(PatternMatchingEventHandler):
Expand Down
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from core.widgets.base import BaseWidget
from core.validation.widgets.example import EXAMPLE_VALIDATION_SCHEMA
from .base import BaseWidget
from ..validation.widgets.example import EXAMPLE_VALIDATION_SCHEMA
from PyQt6.QtWidgets import QLabel


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
from collections import deque
from PyQt6.QtWidgets import QWidget, QLabel
from PyQt6.QtCore import pyqtSignal
from core.utils.win32.utilities import get_monitor_hwnd
from core.event_service import EventService
from core.event_enums import KomorebiEvent
from core.widgets.base import BaseWidget
from core.utils.komorebi.client import KomorebiClient
from core.validation.widgets.komorebi.active_layout import VALIDATION_SCHEMA
from ...utils.win32.utilities import get_monitor_hwnd
from ...event_service import EventService
from ...event_enums import KomorebiEvent
from ..base import BaseWidget
from ...utils.komorebi.client import KomorebiClient
from ...validation.widgets.komorebi.active_layout import VALIDATION_SCHEMA

try:
from core.utils.komorebi.event_listener import KomorebiEventListener
from ...utils.komorebi.event_listener import KomorebiEventListener
except ImportError:
KomorebiEventListener = None
logging.warning("Failed to load Komorebi Event Listener")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from PyQt6.QtCore import pyqtSignal
from typing import Literal
from contextlib import suppress
from core.utils.win32.utilities import get_monitor_hwnd
from core.event_service import EventService
from core.event_enums import KomorebiEvent
from core.widgets.base import BaseWidget
from core.utils.komorebi.client import KomorebiClient
from core.validation.widgets.komorebi.workspaces import VALIDATION_SCHEMA
from ...utils.win32.utilities import get_monitor_hwnd
from ...event_service import EventService
from ...event_enums import KomorebiEvent
from ..base import BaseWidget
from ...utils.komorebi.client import KomorebiClient
from ...validation.widgets.komorebi.workspaces import VALIDATION_SCHEMA

try:
from core.utils.komorebi.event_listener import KomorebiEventListener
from ...utils.komorebi.event_listener import KomorebiEventListener
except ImportError:
KomorebiEventListener = None
logging.warning("Failed to load Komorebi Event Listener")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import logging
from settings import APP_BAR_TITLE
from core.utils.win32.windows import WinEvent
from core.widgets.base import BaseWidget
from core.event_service import EventService
from ....settings import APP_BAR_TITLE
from ...utils.win32.windows import WinEvent
from ..base import BaseWidget
from ...event_service import EventService
from PyQt6.QtCore import pyqtSignal
from PyQt6.QtWidgets import QLabel
from core.validation.widgets.yasb.active_window import VALIDATION_SCHEMA
from core.utils.win32.utilities import get_hwnd_info
from ...validation.widgets.yasb.active_window import VALIDATION_SCHEMA
from ...utils.win32.utilities import get_hwnd_info

IGNORED_TITLES = ['', ' ']
IGNORED_CLASSES = ['WorkerW']
Expand All @@ -20,7 +20,7 @@
]

try:
from core.utils.win32.event_listener import SystemEventListener
from ...utils.win32.event_listener import SystemEventListener
except ImportError:
SystemEventListener = None
logging.warning("Failed to load Win32 System Event Listener")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import psutil
import humanize
from datetime import timedelta
from core.widgets.base import BaseWidget
from core.validation.widgets.yasb.battery import VALIDATION_SCHEMA
from ..base import BaseWidget
from ...validation.widgets.yasb.battery import VALIDATION_SCHEMA
from PyQt6.QtWidgets import QLabel
from typing import Union

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
import pytz
from core.widgets.base import BaseWidget
from core.validation.widgets.yasb.clock import VALIDATION_SCHEMA
from ..base import BaseWidget
from ...validation.widgets.yasb.clock import VALIDATION_SCHEMA
from PyQt6.QtWidgets import QLabel
from datetime import datetime
from tzlocal import get_localzone_name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import psutil
from collections import deque
from core.widgets.base import BaseWidget
from core.validation.widgets.yasb.cpu import VALIDATION_SCHEMA
from ..base import BaseWidget
from ...validation.widgets.yasb.cpu import VALIDATION_SCHEMA
from PyQt6.QtWidgets import QLabel


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import subprocess
import json
from PyQt6.QtWidgets import QLabel
from core.widgets.base import BaseWidget
from core.validation.widgets.yasb.custom import VALIDATION_SCHEMA
from ..base import BaseWidget
from ...validation.widgets.yasb.custom import VALIDATION_SCHEMA


class CustomWidget(BaseWidget):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging
import psutil
from humanize import naturalsize
from core.widgets.base import BaseWidget
from core.validation.widgets.yasb.memory import VALIDATION_SCHEMA
from ..base import BaseWidget
from ...validation.widgets.yasb.memory import VALIDATION_SCHEMA
from PyQt6.QtWidgets import QLabel


Expand Down
17 changes: 9 additions & 8 deletions src/main.py → src/yasb/main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from sys import argv, exit
from PyQt6.QtWidgets import QApplication
from core.bar_manager import BarManager
from core.config import get_config_and_stylesheet
from core.log import init_logger
from core.tray import TrayIcon
from core.watcher import create_observer
from .core.bar_manager import BarManager
from .core.config import get_config_and_stylesheet
from .core.log import init_logger
from .core.tray import TrayIcon
from .core.watcher import create_observer


def main():
def main(log=True):
if log:
init_logger()
config, stylesheet = get_config_and_stylesheet()

app = QApplication(argv)
Expand Down Expand Up @@ -39,5 +41,4 @@ def main():


if __name__ == "__main__":
init_logger()
main()
main(log=True)
File renamed without changes.
File renamed without changes.