mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 13:40:27 +02:00
feat: Refactor code structure to move web-related components to the webui module and update references accordingly
This commit is contained in:
@@ -2,8 +2,8 @@ from pathlib import Path
|
||||
|
||||
from werkzeug.datastructures import MultiDict
|
||||
|
||||
from abogen.web.routes.utils.form import apply_book_step_form
|
||||
from abogen.web.service import PendingJob
|
||||
from abogen.webui.routes.utils.form import apply_book_step_form
|
||||
from abogen.webui.service import PendingJob
|
||||
|
||||
|
||||
def _make_pending_job() -> PendingJob:
|
||||
|
||||
@@ -100,7 +100,7 @@ def _install_dependency_stubs() -> None:
|
||||
_install_dependency_stubs()
|
||||
|
||||
from abogen.text_extractor import ExtractedChapter
|
||||
from abogen.web.conversion_runner import _apply_chapter_overrides, _merge_metadata
|
||||
from abogen.webui.conversion_runner import _apply_chapter_overrides, _merge_metadata
|
||||
|
||||
|
||||
def _sample_chapters() -> list[ExtractedChapter]:
|
||||
|
||||
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from types import SimpleNamespace
|
||||
|
||||
from abogen.chunking import chunk_text
|
||||
from abogen.web.conversion_runner import _chunk_voice_spec, _group_chunks_by_chapter
|
||||
from abogen.webui.conversion_runner import _chunk_voice_spec, _group_chunks_by_chapter
|
||||
|
||||
|
||||
def test_group_chunks_by_chapter_orders_and_groups() -> None:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from abogen.web.conversion_runner import _chunk_text_for_tts
|
||||
from abogen.webui.conversion_runner import _chunk_text_for_tts
|
||||
|
||||
|
||||
def test_chunk_text_for_tts_prefers_text_over_normalized_text():
|
||||
|
||||
@@ -61,7 +61,7 @@ if "bs4" not in sys.modules:
|
||||
sys.modules["bs4"] = bs4_stub
|
||||
|
||||
|
||||
from abogen.web.conversion_runner import (
|
||||
from abogen.webui.conversion_runner import (
|
||||
_format_spoken_chapter_title,
|
||||
_headings_equivalent,
|
||||
_normalize_chapter_opening_caps,
|
||||
|
||||
@@ -61,7 +61,7 @@ if "bs4" not in sys.modules:
|
||||
sys.modules["bs4"] = bs4_stub
|
||||
|
||||
|
||||
from abogen.web.conversion_runner import _build_outro_text, _build_title_intro_text
|
||||
from abogen.webui.conversion_runner import _build_outro_text, _build_title_intro_text
|
||||
|
||||
|
||||
def test_title_intro_includes_series_sentence() -> None:
|
||||
|
||||
@@ -2,12 +2,12 @@ from types import SimpleNamespace
|
||||
from typing import cast
|
||||
|
||||
from abogen.constants import VOICES_INTERNAL
|
||||
from abogen.web.conversion_runner import (
|
||||
from abogen.webui.conversion_runner import (
|
||||
_chapter_voice_spec,
|
||||
_chunk_voice_spec,
|
||||
_collect_required_voice_ids,
|
||||
)
|
||||
from abogen.web.service import Job
|
||||
from abogen.webui.service import Job
|
||||
|
||||
|
||||
def _sample_job(formula: str) -> Job:
|
||||
|
||||
@@ -8,7 +8,7 @@ from abogen.debug_tts_samples import DEBUG_TTS_SAMPLES, MARKER_PREFIX, MARKER_SU
|
||||
from abogen.kokoro_text_normalization import HAS_NUM2WORDS, normalize_for_pipeline
|
||||
from abogen.normalization_settings import build_apostrophe_config
|
||||
from abogen.text_extractor import extract_from_path
|
||||
from abogen.web.app import create_app
|
||||
from abogen.webui.app import create_app
|
||||
|
||||
|
||||
def test_debug_epub_contains_all_codes():
|
||||
@@ -25,7 +25,7 @@ def test_debug_epub_contains_all_codes():
|
||||
|
||||
def test_debug_samples_normalize_smoke():
|
||||
# Use the same defaults as the web UI.
|
||||
from abogen.web.routes.utils.settings import settings_defaults
|
||||
from abogen.webui.routes.utils.settings import settings_defaults
|
||||
|
||||
settings = settings_defaults()
|
||||
apostrophe = build_apostrophe_config(settings=settings)
|
||||
@@ -56,7 +56,7 @@ def test_debug_samples_normalize_smoke():
|
||||
|
||||
def test_settings_debug_route_writes_manifest(tmp_path, monkeypatch):
|
||||
# Avoid pulling Kokoro models in tests: stub the pipeline.
|
||||
from abogen.web import debug_tts_runner as runner
|
||||
from abogen.webui import debug_tts_runner as runner
|
||||
|
||||
class _Seg:
|
||||
def __init__(self, audio):
|
||||
@@ -122,7 +122,7 @@ def test_debug_samples_have_minimum_per_category():
|
||||
|
||||
|
||||
def test_debug_runner_resolves_profile_voice_before_pipeline(tmp_path, monkeypatch):
|
||||
from abogen.web import debug_tts_runner as runner
|
||||
from abogen.webui import debug_tts_runner as runner
|
||||
|
||||
# Stub voice setting resolution so we don't depend on the user's profile file.
|
||||
monkeypatch.setattr(runner, "_resolve_voice_setting", lambda value: ("af_heart", "AM HQ Alt", None))
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from abogen.web.conversion_runner import _render_ffmetadata, _write_ffmetadata_file
|
||||
from abogen.webui.conversion_runner import _render_ffmetadata, _write_ffmetadata_file
|
||||
|
||||
|
||||
def test_render_ffmetadata_includes_chapters(tmp_path):
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from abogen.web import conversion_runner
|
||||
from abogen.webui import conversion_runner
|
||||
|
||||
|
||||
class DummyJob:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from abogen.web.routes.api import _opds_metadata_overrides
|
||||
from abogen.webui.routes.api import _opds_metadata_overrides
|
||||
|
||||
|
||||
def test_opds_metadata_overrides_maps_author_and_subtitle() -> None:
|
||||
|
||||
@@ -5,8 +5,8 @@ from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from abogen.web.conversion_runner import _build_output_path, _prepare_project_layout
|
||||
from abogen.web.service import Job
|
||||
from abogen.webui.conversion_runner import _build_output_path, _prepare_project_layout
|
||||
from abogen.webui.service import Job
|
||||
|
||||
|
||||
def _sample_job(tmp_path: Path) -> Job:
|
||||
@@ -33,7 +33,7 @@ def _sample_job(tmp_path: Path) -> Job:
|
||||
def test_prepare_project_layout_uses_timestamped_folder(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
||||
job = _sample_job(tmp_path)
|
||||
monkeypatch.setattr(
|
||||
"abogen.web.conversion_runner._output_timestamp_token",
|
||||
"abogen.webui.conversion_runner._output_timestamp_token",
|
||||
lambda: "20250101-120000",
|
||||
)
|
||||
|
||||
@@ -52,7 +52,7 @@ def test_prepare_project_layout_creates_project_subdirs(monkeypatch: pytest.Monk
|
||||
job = _sample_job(tmp_path)
|
||||
job.save_as_project = True
|
||||
monkeypatch.setattr(
|
||||
"abogen.web.conversion_runner._output_timestamp_token",
|
||||
"abogen.webui.conversion_runner._output_timestamp_token",
|
||||
lambda: "20250101-120500",
|
||||
)
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ from pathlib import Path
|
||||
|
||||
from werkzeug.datastructures import MultiDict
|
||||
|
||||
from abogen.web.routes.utils.form import apply_prepare_form
|
||||
from abogen.web.routes.utils.voice import resolve_voice_setting
|
||||
from abogen.web.service import PendingJob
|
||||
from abogen.webui.routes.utils.form import apply_prepare_form
|
||||
from abogen.webui.routes.utils.voice import resolve_voice_setting
|
||||
from abogen.webui.service import PendingJob
|
||||
|
||||
|
||||
def _make_pending_job() -> PendingJob:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from abogen.web.routes.utils import preview
|
||||
from abogen.webui.routes.utils import preview
|
||||
|
||||
|
||||
def test_preview_applies_manual_override_before_normalization(monkeypatch):
|
||||
|
||||
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import io
|
||||
import time
|
||||
from abogen.web.service import Job, JobStatus, build_service, _JOB_LOGGER, build_audiobookshelf_metadata
|
||||
from abogen.webui.service import Job, JobStatus, build_service, _JOB_LOGGER, build_audiobookshelf_metadata
|
||||
|
||||
|
||||
def test_service_processes_job(tmp_path):
|
||||
|
||||
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
from abogen.utils import load_config, save_config
|
||||
from abogen.web.app import create_app
|
||||
from abogen.webui.app import create_app
|
||||
|
||||
|
||||
def test_settings_update_preserves_abs_api_token_when_blank(tmp_path):
|
||||
|
||||
@@ -5,8 +5,8 @@ import pytest
|
||||
|
||||
from abogen.constants import VOICES_INTERNAL
|
||||
from abogen.voice_cache import LocalEntryNotFoundError, _CACHED_VOICES, ensure_voice_assets
|
||||
from abogen.web.conversion_runner import _collect_required_voice_ids
|
||||
from abogen.web.service import Job
|
||||
from abogen.webui.conversion_runner import _collect_required_voice_ids
|
||||
from abogen.webui.service import Job
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from abogen.web.conversion_runner import _resolve_voice, _supertonic_voice_from_spec
|
||||
from abogen.webui.conversion_runner import _resolve_voice, _supertonic_voice_from_spec
|
||||
from abogen.tts_supertonic import DEFAULT_SUPERTONIC_VOICES
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user