From 33e5643d4c7be38e34bcee94e2665e77431bb6a6 Mon Sep 17 00:00:00 2001 From: vagabondHustler Date: Wed, 15 May 2024 03:59:21 +0200 Subject: [PATCH 1/7] Refactor update comment --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 708d97ae..c9c02a9e 100644 --- a/.gitignore +++ b/.gitignore @@ -155,7 +155,7 @@ tools/spritesheet_generator/.input tools/spritesheet_generator/package-lock.json tools/spritesheet_generator/node_modules -#Misc +# Test, .env, log related files and folders tests/__subsearch__.log src/subsearch/subsearch.log src/*test* From 4834c43816411ffed343d3b43d5b052d0cfa7860 Mon Sep 17 00:00:00 2001 From: vagabondHustler Date: Wed, 15 May 2024 04:00:29 +0200 Subject: [PATCH 2/7] Refactor remove python 311 and 310 --- tox.ini | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/tox.ini b/tox.ini index 8f712bcf..531e5193 100644 --- a/tox.ini +++ b/tox.ini @@ -1,16 +1,12 @@ [tox] minversion = 4.0 env_list = - py310 - py311 py312 labels = - test = py310, py311 + test = py312 [gh-actions] python = - 3.10: py310 - 3.11: py311 3.12: py312 [testenv] @@ -19,14 +15,6 @@ passenv = PYTHONPATH deps = -e .[tests] isolated_build = true -[testenv:py310] -description = Python 3.10 -commands = pytest --cov - -[testenv:py311] -description = Python 3.11 -commands = pytest --cov - [testenv:py312] description = Python 3.12 commands = pytest --cov \ No newline at end of file From 5cc3e6198dd25aafaaf0b5635f93f3baba9385ce Mon Sep 17 00:00:00 2001 From: vagabondHustler Date: Wed, 15 May 2024 03:54:15 +0200 Subject: [PATCH 3/7] Refactor update type hints - Added generic `DataClass` class for type hinting --- src/subsearch/core.py | 16 ++++++---------- src/subsearch/globals/__init__.py | 4 ++-- src/subsearch/globals/_logging.py | 15 +++++++-------- src/subsearch/globals/dataclasses.py | 8 ++++++-- src/subsearch/providers/yifysubtitles.py | 2 +- 5 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/subsearch/core.py b/src/subsearch/core.py index 8b734875..325f6c72 100644 --- a/src/subsearch/core.py +++ b/src/subsearch/core.py @@ -8,7 +8,7 @@ from subsearch.globals.dataclasses import Subtitle from subsearch.gui import screen_manager, system_tray from subsearch.gui.screens import download_manager -from subsearch.providers import opensubtitles, yifysubtitles +from subsearch.providers import opensubtitles, yifysubtitles from subsearch.utils import io_file_system, io_toml, string_parser @@ -102,24 +102,20 @@ def _create_threads(self, *tasks) -> None: task_thread.start() task_thread.join() - def start_search(self, provider, flag: str = "") -> None: + def _start_search(self, provider, flag: str) -> None: search_provider = provider(**self.search_kwargs) - if flag: - search_provider.start_search(flag=flag) - else: - search_provider.start_search() + search_provider.start_search(flag=flag) self.accepted_subtitles.extend(search_provider.accepted_subtitles) self.rejected_subtitles.extend(search_provider.rejected_subtitles) @decorators.call_func def opensubtitles(self) -> None: - self.start_search(provider=opensubtitles.OpenSubtitles, flag="hash") - self.start_search(provider=opensubtitles.OpenSubtitles, flag="site") - + self._start_search(provider=opensubtitles.OpenSubtitles, flag="hash") + self._start_search(provider=opensubtitles.OpenSubtitles, flag="site") @decorators.call_func def yifysubtitles(self) -> None: - self.start_search(provider=yifysubtitles.YifiSubtitles) + self._start_search(provider=yifysubtitles.YifiSubtitles, flag="site") @decorators.call_func def download_files(self) -> None: diff --git a/src/subsearch/globals/__init__.py b/src/subsearch/globals/__init__.py index a60c8fc7..d3006f16 100644 --- a/src/subsearch/globals/__init__.py +++ b/src/subsearch/globals/__init__.py @@ -1,3 +1,3 @@ -from ._logging import StdoutHandler +from ._logging import Logger -log = StdoutHandler() +log = Logger() diff --git a/src/subsearch/globals/_logging.py b/src/subsearch/globals/_logging.py index cec5e78f..783bc57f 100644 --- a/src/subsearch/globals/_logging.py +++ b/src/subsearch/globals/_logging.py @@ -3,17 +3,16 @@ import threading from datetime import datetime from pathlib import Path -from typing import Optional, TypeVar +from typing import Callable, Optional import picologging as logging from subsearch.globals import metaclasses from subsearch.globals.constants import APP_PATHS, FILE_PATHS +from subsearch.globals.dataclasses import GenericDataClass -DATACLASS = TypeVar("DATACLASS") - -def capture_call_info(func): +def capture_call_info(func) -> Callable[..., None]: def wrapper(*args, **kwargs): frame = inspect.currentframe().f_back # type: ignore current_time = datetime.now().time() @@ -36,7 +35,7 @@ class ANSIEscapeSequences: UNDERLINE = "\033[4m" -class Logger(metaclass=metaclasses.Singleton): +class _Logging(metaclass=metaclasses.Singleton): def __init__(self, *args, **kwargs) -> None: self.logger_name = kwargs.get("logger_name", "subsearch") if not APP_PATHS.appdata_subsearch.exists(): @@ -98,9 +97,9 @@ def _color_print(self, message: str, hex_color: str, style: str) -> None: print(f"{style_code}{color_code}{message}{self._ansi.RESET}") -class StdoutHandler(metaclass=metaclasses.Singleton): +class Logger(metaclass=metaclasses.Singleton): def __init__(self) -> None: - self._logger = Logger() + self._logger = _Logging() def __call__(self, message: str, **kwargs) -> None: self.log(message, **kwargs) @@ -153,7 +152,7 @@ def file_system_action(self, action_type: str, src: Path, dst: Optional[Path] = self(message, **kwargs) @capture_call_info - def dataclass(self, instance: DATACLASS, **kwargs) -> None: + def dataclass(self, instance: GenericDataClass, **kwargs) -> None: if not dataclasses.is_dataclass(instance): raise ValueError("Input is not a dataclass instance.") instance_name = f"--- [{instance.__class__.__name__}] ---" diff --git a/src/subsearch/globals/dataclasses.py b/src/subsearch/globals/dataclasses.py index cbf8d596..8a5a9449 100644 --- a/src/subsearch/globals/dataclasses.py +++ b/src/subsearch/globals/dataclasses.py @@ -1,6 +1,6 @@ -from dataclasses import dataclass +from dataclasses import Field, dataclass from pathlib import Path -from typing import Any +from typing import Any, ClassVar, Protocol @dataclass(order=True) @@ -112,3 +112,7 @@ class WindowsRegistryPaths: shell: str subsearch: str subsearch_command: str + + +class GenericDataClass(Protocol): + __dataclass_fields__: ClassVar[dict[str, Field[Any]]] diff --git a/src/subsearch/providers/yifysubtitles.py b/src/subsearch/providers/yifysubtitles.py index a1257e2a..72e01bb2 100644 --- a/src/subsearch/providers/yifysubtitles.py +++ b/src/subsearch/providers/yifysubtitles.py @@ -42,7 +42,7 @@ def __init__(self, **kwargs) -> None: YifySubtitlesScraper.__init__(self, **kwargs) self.provider_name = self.__class__.__name__.lower() - def start_search(self) -> list[Subtitle] | None: + def start_search(self, **kwargs) -> list[Subtitle] | None: subtitle_data = self.get_subtitle(self.url_yifysubtitles, self.current_language, self.hi_sub, self.non_hi_sub) if not subtitle_data: From a98a4e188846cd1ee41fde17f4be6e52e5ca45a1 Mon Sep 17 00:00:00 2001 From: vagabondHustler Date: Wed, 15 May 2024 04:03:36 +0200 Subject: [PATCH 4/7] Refactor update MANIFEST.in - Include readme and license file - Exclude .pyc files --- MANIFEST.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index 27857839..48112e01 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,6 @@ +include README.md +include LICENSE + graft src exclude tox.ini @@ -6,4 +9,6 @@ prune assets prune tests prune */.pytest_cache -global-exclude */__pycache__/* *.log \ No newline at end of file +global-exclude */__pycache__/* +global-exclude *.log +global-exclude *.pyc \ No newline at end of file From 99f5edf0df4495758fc201d480cf6a04e0e37069 Mon Sep 17 00:00:00 2001 From: vagabondHustler Date: Wed, 15 May 2024 02:06:31 +0000 Subject: [PATCH 5/7] Bump version to 2.46.0dev0 --- .github/configs/version_control.json | 4 ++-- src/subsearch/data/version.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/configs/version_control.json b/.github/configs/version_control.json index 548b940e..22060a33 100644 --- a/.github/configs/version_control.json +++ b/.github/configs/version_control.json @@ -1,5 +1,5 @@ { - "current_version": "2.45.1", - "previous_version": "2.45.1dev0", + "current_version": "2.46.0dev0", + "previous_version": "2.45.1", "last_stable_release": "2.45.1" } \ No newline at end of file diff --git a/src/subsearch/data/version.py b/src/subsearch/data/version.py index 99ca0c3d..8b83e387 100644 --- a/src/subsearch/data/version.py +++ b/src/subsearch/data/version.py @@ -1 +1 @@ -__version__ = "2.45.1" +__version__ = "2.46.0dev0" From 77de369450bf8b25ba129a4e7adc7cc8a777c37c Mon Sep 17 00:00:00 2001 From: vagabondHustler Date: Wed, 15 May 2024 13:26:01 +0000 Subject: [PATCH 6/7] Bump version to 2.46.0 --- .github/configs/version_control.json | 6 +++--- src/subsearch/data/version.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/configs/version_control.json b/.github/configs/version_control.json index 22060a33..8ac6b33f 100644 --- a/.github/configs/version_control.json +++ b/.github/configs/version_control.json @@ -1,5 +1,5 @@ { - "current_version": "2.46.0dev0", - "previous_version": "2.45.1", - "last_stable_release": "2.45.1" + "current_version": "2.46.0", + "previous_version": "2.46.0dev0", + "last_stable_release": "2.46.0" } \ No newline at end of file diff --git a/src/subsearch/data/version.py b/src/subsearch/data/version.py index 8b83e387..9c6da0a4 100644 --- a/src/subsearch/data/version.py +++ b/src/subsearch/data/version.py @@ -1 +1 @@ -__version__ = "2.46.0dev0" +__version__ = "2.46.0" From b442645938a6a6dbc8ba0a54ee30fbde869f0637 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 3 Jul 2024 12:10:07 +0000 Subject: [PATCH 7/7] Bump tox from 4.15.0 to 4.16.0 Bumps [tox](https://github.com/tox-dev/tox) from 4.15.0 to 4.16.0. - [Release notes](https://github.com/tox-dev/tox/releases) - [Changelog](https://github.com/tox-dev/tox/blob/main/docs/changelog.rst) - [Commits](https://github.com/tox-dev/tox/compare/4.15.0...4.16.0) --- updated-dependencies: - dependency-name: tox dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 20e5c97a..04c35708 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,7 +78,7 @@ tests = [ "pytest-cov==5.0.0", "pytest==8.2.0", - "tox==4.15.0", + "tox==4.16.0", "python-dotenv==1.0.1", ] tools = ["pyperclip==1.8.2"]