From c92d32a392ab241703e719b65206474d402e0b06 Mon Sep 17 00:00:00 2001 From: WorldTeacher Date: Tue, 25 Mar 2025 21:47:11 +0100 Subject: [PATCH 1/3] enable tag creation --- .bumpversion.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index 29ac94f..48a6489 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -7,7 +7,7 @@ replace = "{new_version}" regex = false ignore_missing_version = false ignore_missing_files = false -tag = false +tag = true sign_tags = false tag_name = "v{new_version}" tag_message = "Bump version: {current_version} → {new_version}" From 5aece5c5db12fed2c7fee8390d09a20070110c40 Mon Sep 17 00:00:00 2001 From: WorldTeacher Date: Tue, 25 Mar 2025 21:47:19 +0100 Subject: [PATCH 2/3] =?UTF-8?q?Bump=20version:=200.1.5=20=E2=86=92=200.1.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.toml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index 48a6489..0c2f608 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -1,5 +1,5 @@ [tool.bumpversion] -current_version = "0.1.5" +current_version = "0.1.6" parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)" serialize = ["{major}.{minor}.{patch}"] search = "{current_version}" diff --git a/pyproject.toml b/pyproject.toml index d64113f..bfea104 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "komconfig" -version = "0.1.5" +version = "0.1.6" description = "A small library providing a config class that provides settings data for the KomSuite" readme = "README.md" authors = [{ name = "WorldTeacher", email = "coding_contact@pm.me" }] From 0d24c0a95cafaf2d662598d9c2df2f2d9023f4f2 Mon Sep 17 00:00:00 2001 From: WorldTeacher Date: Sun, 18 May 2025 19:06:04 +0200 Subject: [PATCH 3/3] update files, add issue templates, --- .gitea/ISSUE_TEMPLATE/bug.yml | 34 +++++++++++ .gitea/ISSUE_TEMPLATE/feature.yml | 23 ++++++++ .gitea/workflows/build.yaml | 1 + src/komconfig/__init__.py | 1 + src/komconfig/config.py | 95 ++++++++++++++++++++++++++++--- 5 files changed, 146 insertions(+), 8 deletions(-) create mode 100644 .gitea/ISSUE_TEMPLATE/bug.yml create mode 100644 .gitea/ISSUE_TEMPLATE/feature.yml diff --git a/.gitea/ISSUE_TEMPLATE/bug.yml b/.gitea/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..8f78e72 --- /dev/null +++ b/.gitea/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,34 @@ +name: Bug Report +description: Report a bug in this project +labels: + - kind/bug + - triage +body: + + - type: textarea + id: bug + attributes: + label: Describe the bug + description: | + A clear and concise description of what the bug is. + What did you expect to happen? What happened instead? + Include screenshots if applicable. + validations: + required: true + - type: textarea + id: reproduction + attributes: + label: Steps to reproduce + description: | + A clear and concise description of how to reproduce the bug. + Include steps, code snippets, or screenshots if applicable. + validations: + required: true + - type: textarea + id: additional-info + attributes: + label: Additional information + description: | + Add any other context or screenshots about the bug here. + + \ No newline at end of file diff --git a/.gitea/ISSUE_TEMPLATE/feature.yml b/.gitea/ISSUE_TEMPLATE/feature.yml new file mode 100644 index 0000000..cb6338e --- /dev/null +++ b/.gitea/ISSUE_TEMPLATE/feature.yml @@ -0,0 +1,23 @@ +name: Feature request +description: Suggest an idea for this project +labels: + - kind/feature + - triage + +body: + - type: textarea + id: feature + attributes: + label: Describe the feature + description: | + A clear and concise description of what the feature is. + What is the problem it solves? What are you trying to accomplish? + Include screenshots if applicable. + validations: + required: true + - type: textarea + id: additional-info + attributes: + label: Additional information + description: | + Add any other context or screenshots about the feature request here. \ No newline at end of file diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index ffd38ec..47550ab 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -5,6 +5,7 @@ on: push: branches: - main + jobs: build: runs-on: ubuntu-latest diff --git a/src/komconfig/__init__.py b/src/komconfig/__init__.py index 088a728..721bd96 100644 --- a/src/komconfig/__init__.py +++ b/src/komconfig/__init__.py @@ -1 +1,2 @@ +CONFIG_PATH = "~/.config/KomSuite/" from .config import Settings as KomConfig diff --git a/src/komconfig/config.py b/src/komconfig/config.py index 090814a..0c3adad 100644 --- a/src/komconfig/config.py +++ b/src/komconfig/config.py @@ -1,8 +1,11 @@ from dataclasses import dataclass from typing import List, Optional import os -from omegaconf import OmegaConf -from omegaconf import DictConfig +from omegaconf import OmegaConf, DictConfig +from pathlib import Path +from komconfig import CONFIG_PATH + +SETTINGS_PATH = os.path.join(CONFIG_PATH, "config.yaml") @dataclass @@ -14,6 +17,7 @@ class Komga: password: str media_path: str api_key: str = None + libraries: dict[str, str] = None def getattr(self, name): return getattr(self, name) @@ -58,20 +62,93 @@ class Aria2: @dataclass -class KomGrabber: - """KomGrabber settings.""" +class EbookSettings: + min_filesize: int + max_filesize: int + data_directory: str + skip_parameters: List[str] + valid_file_extensions: List[str] - download_location: str + def __post_init__(self): + self.skip_parameters = [ + param.lower() for param in self.skip_parameters if param is not None + ] + + def getattr(self, name): + return getattr(self, name) + + def _setattr(self, name, value): + setattr(self, name, value) + + +@dataclass +class ComicSettings: + min_filesize: int + max_filesize: int + data_directory: str + valid_file_extensions: List[str] + + skip_parameters: List[str] + + def __post_init__(self): + self.skip_parameters = [ + param.lower() for param in self.skip_parameters if param is not None + ] + + def getattr(self, name): + return getattr(self, name) + + def _setattr(self, name, value): + setattr(self, name, value) + + +@dataclass +class KomGrabber: + """ + Configs used by the KomGrabber. + + Attributes + ---------- + download_location : str | Path + The location to download the files to. + get_chapters : bool + Whether to get chapters or not. + skip_parameters : List[str] + A list of parameters to skip. + aria2 : Aria2 + The aria2 settings. see Aria2 class. + tag_interactive : bool + Whether to use interactive tagging or not. + ebook : EbookSettings + The ebook settings. see EbookSettings class. + manga : ComicSettings + The manga settings. see ComicSettings class. + check_interval : int + The interval to check for new files. + use_cache : bool + Whether to use cache or not. + cache_check_interval : int + The days an entry will not be checked based on the last change in the cache. + + """ + + download_location: Path get_chapters: bool skip_parameters: List[str] aria2: Aria2 tag_interactive: bool - min_filesize: int + ebook: EbookSettings + manga: ComicSettings + check_interval: int + use_cache: bool + cache_check_interval: int def __post_init__(self): self.skip_parameters = [param.lower() for param in self.skip_parameters] if "~" in self.download_location: self.download_location = os.path.expanduser(self.download_location) + if isinstance(self.download_location, str): + self.download_location = Path(self.download_location) def getattr(self, name): return getattr(self, name) @@ -186,7 +263,7 @@ class Settings: _config: Optional[DictConfig] = None - def __init__(self, config_path: str = "~/.config/KomSuite/config.yaml"): + def __init__(self, config_path: str = SETTINGS_PATH): """ Loads the configuration file and stores it for future access. @@ -196,7 +273,9 @@ class Settings: Raises: FileNotFoundError: Configuration file not found """ - if not os.path.exists(os.path.expanduser(config_path)): + if "~" in config_path: + config_path = os.path.expanduser(config_path) + if not os.path.exists(config_path): raise FileNotFoundError(f"Configuration file not found: {config_path}") self._config = OmegaConf.load(os.path.expanduser(config_path)) self.config_path = config_path