Merge pull request 'dev' (#4) from dev into main
All checks were successful
/ build (push) Successful in 24s

Reviewed-on: #4
This commit was merged in pull request #4.
This commit is contained in:
2025-05-18 18:06:56 +01:00
7 changed files with 149 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "0.1.5"
current_version = "0.1.6"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
serialize = ["{major}.{minor}.{patch}"]
search = "{current_version}"
@@ -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}"

View File

@@ -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.

View File

@@ -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.

View File

@@ -5,6 +5,7 @@ on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest

View File

@@ -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" }]

View File

@@ -1 +1,2 @@
CONFIG_PATH = "~/.config/KomSuite/"
from .config import Settings as KomConfig

View File

@@ -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