18 Commits
dev ... v0.2.2

Author SHA1 Message Date
Gitea CI
f67ebededd Bump version: 0.2.1 → 0.2.2 2025-05-29 09:35:36 +00:00
79846dfed5 Merge pull request 'update workflow, adjust release to include v to release tag' (#13) from dev into main
Reviewed-on: #13
2025-05-29 10:35:14 +01:00
Gitea CI
9b20484753 Bump version: 0.2.0 → 0.2.1 2025-05-29 09:32:44 +00:00
e5ede589e7 Merge pull request 'dev to main' (#12) from dev into main
Reviewed-on: #12
2025-05-29 10:32:23 +01:00
c7089edfdc Delete .bumpversion.toml 2025-05-29 10:31:28 +01:00
Gitea CI
d4ef36a54b Bump version: 0.1.9 → 0.2.0 2025-05-23 14:52:49 +00:00
8a0b73c60d Merge pull request 'refactor: update release notes handling in build workflow' (#10) from dev into main
Reviewed-on: #10
2025-05-23 15:50:59 +01:00
Gitea CI
8d8e7549f6 Bump version: 0.1.8 → 0.1.9 2025-05-23 14:47:46 +00:00
5f09116071 Merge pull request 'refactor: remove changelog generation and use release notes for release body' (#9) from dev into main
Reviewed-on: #9
2025-05-23 15:46:55 +01:00
Gitea CI
ea68370451 Bump version: 0.1.7 → 0.1.8 2025-05-23 14:43:37 +00:00
2343d66fe2 Merge pull request 'fix: update changelog generator token to use GITHUB_TOKEN' (#8) from dev into main
Reviewed-on: #8
2025-05-23 15:43:10 +01:00
Gitea CI
386fa02ff9 Bump version: 0.1.6 → 0.1.7 2025-05-23 14:22:31 +00:00
4add66496b Merge pull request 'add git ghost identity' (#7) from dev into main
Reviewed-on: #7
2025-05-23 15:07:00 +01:00
b1432e8a85 Merge pull request 'change wf order to bump before attempting to push builds' (#6) from dev into main
Reviewed-on: #6
2025-05-23 15:01:59 +01:00
2a9958fbed Merge pull request 'update komconfig workflow' (#5) from dev into main
Reviewed-on: #5
2025-05-23 14:58:59 +01:00
7d438bcd3e Merge pull request 'dev' (#4) from dev into main
All checks were successful
/ build (push) Successful in 24s
Reviewed-on: #4
2025-05-18 18:06:56 +01:00
WorldTeacher
7090920424 Merge pull request 'bump to 0.1.5' (#2) from dev into main
Some checks failed
/ build (push) Failing after 1m5s
Reviewed-on: #2
2025-03-16 10:11:01 +00:00
WorldTeacher
f308c60525 Merge pull request 'use token instead of username/password' (#1) from dev into main
All checks were successful
/ build (push) Successful in 11s
Reviewed-on: #1
2025-03-16 10:08:58 +00:00
11 changed files with 42 additions and 363 deletions

View File

@@ -1,103 +0,0 @@
{
"categories": [
{
"title": "## 🚀 Features",
"labels": [
"add",
"Add",
"Kind/Feature",
"feat",
"Feature",
"Feat"
]
},
{
"title": "## 🧰 Enhancements",
"labels": [
"enhancement",
"Enhancement",
"Kind/Enhancement",
"improvement",
"Improvement",
"Kind/Improvement"
]
},
{
"title": "## 🐛 Fixes",
"labels": [
"fix",
"Fix",
"Kind/Bug",
"Kind/Security"
]
},
{
"title": "## 🧪 Upgrade",
"labels": ["upgrade","Upgrade","Clean"]
}
,
{
"title": "## 📝 Documentation",
"labels": ["docs","Docs", "Kind/Documentation"]
},
{
"title": "## 🛠️ Maintenance",
"labels": [
"maintenance",
"Maintenance",
"Kind/Maintenance",
"chore",
"Chore",
"Kind/Chore"
]
},
{
"title": "## ⏪ Reverts",
"labels": [
"revert",
"Revert",
"Kind/Revert",
"Kind/Reverts",
"reverts",
"Reverts"
]
},
{
"title": "## 🗑️ Deprecation",
"labels": ["deprecation","Deprecation", "Kind/Deprecation"]
},
{
"title": "## ⚡️ Performance Improvements",
"labels": [
"perf",
"Perf",
"Kind/Performance"
]
},
{
"title": "## 🎨 Styling",
"labels": [
"style",
"Style",
"Kind/Style"
]
},
{
"title": "## 🎯 Other Changes",
"labels": []
}
],
"label_extractor": [
{
"pattern": "(\\w+) (.+)",
"target": "$1",
"on_property": "title"
}
],
"sort": "ASC",
"template": "${{CHANGELOG}}",
"pr_template": "- ${{TITLE}}\n - PR: #${{NUMBER}}",
"empty_template": "- no changes",
"max_pull_requests": 1000,
"max_back_track_time_days": 1000
}

View File

@@ -25,8 +25,6 @@ jobs:
uses: astral-sh/setup-uv@v5 uses: astral-sh/setup-uv@v5
- name: Set up Python - name: Set up Python
run: uv python install run: uv python install
with:
python-version-file: "pyproject.toml"
- name: Set Git identity - name: Set Git identity
run: | run: |
git config user.name "Gitea CI" git config user.name "Gitea CI"
@@ -51,7 +49,7 @@ jobs:
uses: https://github.com/mikepenz/release-changelog-builder-action@v5 uses: https://github.com/mikepenz/release-changelog-builder-action@v5
with: with:
platform: "gitea" platform: "gitea"
baseURL: "http://192.168.178.110:3000" baseURL: "http://gitea:3000"
configuration: ".gitea/changelog-config.json" configuration: ".gitea/changelog-config.json"
env: env:
GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }}

View File

@@ -1,7 +0,0 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}

View File

@@ -1,9 +0,0 @@
from src.komconfig import KomConfig
def test_komconfig():
print(KomConfig().general.log_file)
if __name__ == "__main__":
test_komconfig()

View File

@@ -1,30 +1,21 @@
[project] [project]
name = "komconfig" name = "komconfig"
version = "0.2.0" version = "0.2.2"
description = "A small library providing a config class that provides settings data for the KomSuite" description = "A small library providing a config class that provides settings data for the KomSuite"
readme = "README.md" readme = "README.md"
authors = [{ name = "WorldTeacher", email = "coding_contact@pm.me" }] authors = [{ name = "WorldTeacher", email = "coding_contact@pm.me" }]
requires-python = ">=3.13" requires-python = ">=3.13"
dependencies = [ dependencies = ["omegaconf>=2.3.0"]
"appdirs>=1.4.4",
"omegaconf>=2.3.0",
]
[build-system] [build-system]
requires = ["hatchling"] requires = ["hatchling"]
build-backend = "hatchling.build" build-backend = "hatchling.build"
[dependency-groups] [dependency-groups]
dev = [ test = ["pytest>=8.3.4"]
"pip>=25.1.1",
]
test = [
"pytest>=8.3.4",
"pytest-cov>=6.1.1",
]
[tool.bumpversion] [tool.bumpversion]
current_version = "0.2.0" current_version = "0.2.2"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)" parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
serialize = ["{major}.{minor}.{patch}"] serialize = ["{major}.{minor}.{patch}"]
search = "{current_version}" search = "{current_version}"

View File

@@ -1,38 +1,2 @@
__all__ = ["KomConfig", "app"] CONFIG_PATH = "~/.config/KomSuite/"
from appdirs import AppDirs
app = AppDirs("KomSuite", "KomConfig")
import argparse
from .config import Settings as KomConfig from .config import Settings as KomConfig
def main():
parser = argparse.ArgumentParser(description="Retrieve configuration values.")
parser.add_argument("key", type=str, help="The configuration key to retrieve.")
args = parser.parse_args()
config = KomConfig()
try:
config_dict = config.dict()
if isinstance(config_dict, dict):
value = config_dict.get(args.key, None)
if value is None:
print(f"Key '{args.key}' not found in the configuration.")
else:
try:
print(str(value))
except Exception:
print(repr(value))
else:
print("Configuration data is not in dictionary format.")
except Exception as e:
print(f"Error retrieving key '{args.key}': {e}")
if __name__ == "__main__":
main()

View File

@@ -1,30 +0,0 @@
import argparse
from src.komconfig import KomConfig
def main():
parser = argparse.ArgumentParser(description="Retrieve configuration values.")
parser.add_argument("key", type=str, help="The configuration key to retrieve.")
args = parser.parse_args()
config = KomConfig()
try:
config_dict = config.dict()
if isinstance(config_dict, dict):
value = config_dict.get(args.key, None)
if value is None:
print(f"Key '{args.key}' not found in the configuration.")
else:
try:
print(str(value))
except Exception:
print(repr(value))
else:
print("Configuration data is not in dictionary format.")
except Exception as e:
print(f"Error retrieving key '{args.key}': {e}")
if __name__ == "__main__":
main()

View File

@@ -1,16 +1,12 @@
import os
from dataclasses import dataclass from dataclasses import dataclass
from pathlib import Path
from typing import List, Optional, Union from typing import List, Optional, Union
import os
from omegaconf import OmegaConf, DictConfig
from pathlib import Path
from komconfig import CONFIG_PATH
from urllib.parse import quote_plus from urllib.parse import quote_plus
from omegaconf import DictConfig, OmegaConf SETTINGS_PATH = os.path.join(CONFIG_PATH, "config.yaml")
from komconfig import app
SETTINGS_PATH = os.path.join(app.user_config_dir, "config.yaml")
@dataclass @dataclass
class RemoteSettings: class RemoteSettings:
url: str url: str
@@ -23,9 +19,11 @@ class RemoteSettings:
@dataclass @dataclass
class Cache: class Cache:
mode: str mode: str
remote: dict[str, Union[str, int]] | RemoteSettings remote: dict[str, Union[str, int]] |RemoteSettings
local_path: str | Path local_path: str | Path
def __post__init__(self): def __post__init__(self):
if self.mode == "remote": if self.mode == "remote":
self.remote = RemoteSettings(**self.remote) self.remote = RemoteSettings(**self.remote)
@@ -45,27 +43,6 @@ class Cache:
password = quote_plus(self.remote.password) if self.remote else "" password = quote_plus(self.remote.password) if self.remote else ""
return f"mysql+pymysql://{self.remote.user}:{password}@{self.remote.url}:{self.remote.port}/{self.remote.database_name}" return f"mysql+pymysql://{self.remote.user}:{password}@{self.remote.url}:{self.remote.port}/{self.remote.database_name}"
@dataclass
class Library:
"""Komga library settings."""
id: Optional[str] = None
name: Optional[str] = None
type: Optional[str] = None
media_path: Optional[str] = None
valid_extensions: Optional[List[str]] = None
def from_ddict(self, d: dict):
keys = d.keys()
for key in keys:
self.name = key
data = d[self.name]
for key, value in data.items():
setattr(self, key, value)
return self
@dataclass @dataclass
class Komga: class Komga:
"""Komga server settings.""" """Komga server settings."""
@@ -73,9 +50,9 @@ class Komga:
url: str url: str
user: str user: str
password: str password: str
media_path: Path media_path: str
api_key: str = None api_key: str = None
libraries: List[Library] = None libraries: dict[str, str] = None
def getattr(self, name): def getattr(self, name):
return getattr(self, name) return getattr(self, name)
@@ -85,24 +62,7 @@ class Komga:
def __post_init__(self): def __post_init__(self):
if "~" in self.media_path: if "~" in self.media_path:
self.media_path = Path(os.path.expanduser(self.media_path)) self.media_path = os.path.expanduser(self.media_path)
if self.libraries:
self.libraries = [Library().from_ddict(lib) for lib in self.libraries]
def getLibraryByName(self, name: str) -> Optional[Library]:
"""Get a library by its name.
Args:
name (str): The name of the library.
Returns:
Optional[Library]: The library object if found, None otherwise.
"""
if self.libraries:
for lib in self.libraries:
if lib.name == name:
return lib
return None
@dataclass @dataclass
@@ -136,23 +96,6 @@ class Aria2:
setattr(self, name, value) setattr(self, name, value)
@dataclass
class QbitTorrent:
"""QbitTorrent settings."""
host: str
port: int
username: str
password: str
category: str
def getattr(self, name):
return getattr(self, name)
def _setattr(self, name, value):
setattr(self, name, value)
@dataclass @dataclass
class EbookSettings: class EbookSettings:
min_filesize: int min_filesize: int
@@ -225,35 +168,22 @@ class KomGrabber:
""" """
download_location: Path download_location: Path
tag_location: Path
copy_location: Optional[Path]
copy_files: Optional[List[str]]
copy: bool
get_chapters: bool get_chapters: bool
skip_parameters: List[str] skip_parameters: List[str]
aria2: Aria2
tag_interactive: bool tag_interactive: bool
ebook: EbookSettings ebook: EbookSettings
manga: ComicSettings manga: ComicSettings
check_interval: int check_interval: int
use_cache: bool use_cache: bool
cache_check_interval: int cache_check_interval: int
downloader: str
downloader_settings: Union[Aria2, QbitTorrent]
def __post_init__(self): def __post_init__(self):
self.skip_parameters = [param.lower() for param in self.skip_parameters] self.skip_parameters = [param.lower() for param in self.skip_parameters]
# if "~" in self.download_location: if "~" in self.download_location:
# self.download_location = os.path.expanduser(self.download_location) self.download_location = os.path.expanduser(self.download_location)
if isinstance(self.download_location, str): if isinstance(self.download_location, str):
self.download_location = Path(self.download_location).expanduser() self.download_location = Path(self.download_location)
if isinstance(self.tag_location, str):
self.tag_location = Path(self.tag_location).expanduser()
if isinstance(self.downloader_settings, dict):
if self.downloader == "aria2":
self.downloader_settings = Aria2(**self.downloader_settings)
elif self.downloader == "qbit":
self.downloader_settings = QbitTorrent(**self.downloader_settings)
def getattr(self, name): def getattr(self, name):
return getattr(self, name) return getattr(self, name)
@@ -266,9 +196,9 @@ class KomGrabber:
class KomTagger: class KomTagger:
"""KomTagger settings.""" """KomTagger settings."""
failed_location: str
success_location: str
sanitize_description: bool sanitize_description: bool
check_cache: bool
check_interval: int
def getattr(self, name): def getattr(self, name):
return getattr(self, name) return getattr(self, name)
@@ -277,15 +207,18 @@ class KomTagger:
setattr(self, name, value) setattr(self, name, value)
def __post_init__(self): def __post_init__(self):
pass if "~" in self.failed_location:
self.failed_location = os.path.expanduser(self.failed_location)
if "~" in self.success_location:
self.success_location = os.path.expanduser(self.success_location)
@dataclass @dataclass
class ComicVine: class ComicVine:
"""ComicVine settings.""" """ComicVine settings."""
url: str
api_key: str api_key: str
url: str
def getattr(self, name): def getattr(self, name):
return getattr(self, name) return getattr(self, name)
@@ -334,11 +267,17 @@ class API:
mangadex: MangaDex mangadex: MangaDex
comicsorg: ComicsOrg comicsorg: ComicsOrg
def __post_init__(self): @property
# Convert dictionaries to their respective dataclass objects def comicvine(self):
self.comicvine = ComicVine(**self.comicvine) return self.comicvine
self.mangadex = MangaDex(**self.mangadex)
self.comicsorg = ComicsOrg(**self.comicsorg) @property
def mangadex(self):
return self.mangadex
@property
def comicsorg(self):
return self.comicsorg
def getattr(self, name): def getattr(self, name):
return getattr(self, name) return getattr(self, name)

View File

@@ -1,6 +0,0 @@
from src.komconfig import KomConfig
cfg = KomConfig()
print(cfg.komga.libraries)

View File

@@ -1,40 +0,0 @@
import pytest
from unittest.mock import patch, MagicMock
from src.komconfig.__init__ import main
import sys
def test_valid_key():
mock_config = MagicMock()
mock_config.dict.return_value = {"valid_key": "value"}
with patch("src.komconfig.__init__.KomConfig", return_value=mock_config):
with patch("sys.argv", ["__init__.py", "valid_key"]):
main()
def test_key_not_found():
mock_config = MagicMock()
mock_config.dict.return_value = {"another_key": "value"}
with patch("src.komconfig.__init__.KomConfig", return_value=mock_config):
with patch("sys.argv", ["__init__.py", "missing_key"]):
main()
def test_non_dict_config():
mock_config = MagicMock()
mock_config.dict.return_value = None
with patch("src.komconfig.__init__.KomConfig", return_value=mock_config):
with patch("sys.argv", ["__init__.py", "any_key"]):
main()
def test_exception_handling():
mock_config = MagicMock()
mock_config.dict.side_effect = Exception("Test Exception")
with patch("src.komconfig.__init__.KomConfig", return_value=mock_config):
with patch("sys.argv", ["__init__.py", "any_key"]):
main()

View File

@@ -1,18 +0,0 @@
from komconfig import KomConfig
import pytest
@pytest.fixture
def komconfig():
return KomConfig()
def test_komconfig(komconfig):
assert komconfig is not None
def test_general(komconfig):
assert KomConfig().general.log_file == "/var/log/komgrabber.log"
assert KomConfig().general.log_level == "INFO"