Gather the CLI command modules into a commands sub-package

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-17 22:38:26 +08:00
co-authored by Claude Fable 5
parent 396848e898
commit b727284ef3
17 changed files with 128 additions and 82 deletions
+11 -11
View File
@@ -15,23 +15,23 @@ from collections.abc import Callable
from importlib.machinery import ModuleSpec
from types import ModuleType
from pop_fem_audit_tools import (
build_db,
export_llm_input,
fetch_artists,
fetch_lyrics,
run_llm,
from .commands import (
build_db_command,
export_llm_input_command,
fetch_artists_command,
fetch_lyrics_command,
run_llm_command,
)
MODULE_PROG: str = "python -m pop_fem_audit_tools"
"""The program name when run with ``python -m``."""
SUBCOMMANDS: dict[str, Callable[[list[str] | None], int]] = {
"build-db": build_db.main,
"export-llm-input": export_llm_input.main,
"fetch-artists": fetch_artists.main,
"fetch-lyrics": fetch_lyrics.main,
"run-llm": run_llm.main,
"build-db": build_db_command,
"export-llm-input": export_llm_input_command,
"fetch-artists": fetch_artists_command,
"fetch-lyrics": fetch_lyrics_command,
"run-llm": run_llm_command,
}
"""The dispatch table from the subcommand name to the tool main."""
@@ -0,0 +1,10 @@
# Tools for A Feminist Audit of Pop Music.
# Copyright 2026 imacat. All rights reserved.
# Authors:
# imacat@mail.imacat.idv.tw (imacat), 2026/8/4
"""The registry of the CLI subcommands."""
from .build_db import main as build_db_command
from .export_llm_input import main as export_llm_input_command
from .fetch_artists import main as fetch_artists_command
from .fetch_lyrics import main as fetch_lyrics_command
from .run_llm import main as run_llm_command
@@ -59,8 +59,8 @@ from typing import Any, Self
import sqlalchemy as sa
from sqlalchemy.orm import Session
from .database import Base, ds
from .models import (
from ..database import Base, ds
from ..models import (
Artist,
ChartEntry,
Role,
@@ -19,8 +19,8 @@ from pathlib import Path
import sqlalchemy as sa
from sqlalchemy.orm import Session
from .database import ds
from .models import Song
from ..database import ds
from ..models import Song
def parse_args(argv: list[str] | None) -> argparse.Namespace:
@@ -34,10 +34,10 @@ from typing import Any, Literal, TextIO
import sqlalchemy as sa
from sqlalchemy.orm import Session
from . import VERSION
from .database import ds
from .models import Artist, Song, SongArtist
from .utils import format_duration
from .. import VERSION
from ..database import ds
from ..models import Artist, Song, SongArtist
from ..utils import format_duration
API_URL: str = "https://www.wikidata.org/w/api.php"
"""The URL of the Wikidata API endpoint."""
@@ -36,14 +36,14 @@ from typing import Any
import sqlalchemy as sa
from sqlalchemy.orm import Session
from .database import ds
from .models import (
from ..database import ds
from ..models import (
Artist,
Role,
Song,
SongArtist,
)
from .utils import format_duration
from ..utils import format_duration
PROVENANCE_FIELDS: Sequence[str] = (
"song_id", "source", "method", "acquired_at", "note")
@@ -26,7 +26,7 @@ from typing import Any, Self
import anthropic
from .config import get_settings
from ..config import get_settings
MODEL: str = "claude-sonnet-4-6"
TEMPERATURE: float = 0.0