Add YAPF style + ignore, and format tracked Python files

This commit is contained in:
2025-12-29 18:42:02 -08:00
parent c019c00aed
commit 507946a3e4
108 changed files with 11664 additions and 6494 deletions

View File

@@ -14,7 +14,7 @@ import asyncio
# Add parent directory to path for imports
sys.path.insert(0, str(Path(__file__).parent.parent))
from config import load_config, resolve_output_dir
from SYS.config import load_config, resolve_output_dir
from result_table import ResultTable
from ProviderCore.registry import get_search_provider
@@ -25,9 +25,15 @@ class SearchModal(ModalScreen):
"""Modal screen for searching OpenLibrary and Soulseek."""
BINDINGS = [
Binding("escape", "cancel", "Cancel"),
Binding("enter", "search_focused", "Search"),
Binding("ctrl+t", "scrape_tags", "Scrape Tags"),
Binding("escape",
"cancel",
"Cancel"),
Binding("enter",
"search_focused",
"Search"),
Binding("ctrl+t",
"scrape_tags",
"Scrape Tags"),
]
CSS_PATH = "search.tcss"
@@ -65,14 +71,20 @@ class SearchModal(ModalScreen):
with Horizontal(id="search-controls"):
# Source selector
self.source_select = Select(
[("OpenLibrary", "openlibrary"), ("Soulseek", "soulseek")],
[("OpenLibrary",
"openlibrary"),
("Soulseek",
"soulseek")],
value="openlibrary",
id="source-select",
)
yield self.source_select
# Search input
self.search_input = Input(placeholder="Enter search query...", id="search-input")
self.search_input = Input(
placeholder="Enter search query...",
id="search-input"
)
yield self.search_input
# Search button
@@ -87,7 +99,9 @@ class SearchModal(ModalScreen):
# Left column: Tags textarea
with Vertical(id="tags-column"):
self.tags_textarea = TextArea(
text="", id="result-tags-textarea", read_only=False
text="",
id="result-tags-textarea",
read_only=False
)
self.tags_textarea.border_title = "Tags [Ctrl+T: Scrape]"
yield self.tags_textarea
@@ -96,7 +110,10 @@ class SearchModal(ModalScreen):
with Vertical(id="source-submit-column"):
# Library source selector (for OpenLibrary results)
self.library_source_select = Select(
[("Local", "local"), ("Download", "download")],
[("Local",
"local"),
("Download",
"download")],
value="local",
id="library-source-select",
)
@@ -114,7 +131,12 @@ class SearchModal(ModalScreen):
def on_mount(self) -> None:
"""Set up the table columns and focus."""
# Set up results table columns
self.results_table.add_columns("Title", "Author/Artist", "Year/Album", "Details")
self.results_table.add_columns(
"Title",
"Author/Artist",
"Year/Album",
"Details"
)
# Focus on search input
self.search_input.focus()
@@ -153,7 +175,10 @@ class SearchModal(ModalScreen):
if not provider:
logger.error(f"[search-modal] Provider not available: {source}")
if self.current_worker:
self.current_worker.finish("error", f"Provider not available: {source}")
self.current_worker.finish(
"error",
f"Provider not available: {source}"
)
return
logger.info(f"[search-modal] Searching {source} for: {query}")
@@ -176,10 +201,13 @@ class SearchModal(ModalScreen):
row.add_column("Title", res.title)
row.add_column(
"Target",
getattr(res, "path", None)
or getattr(res, "url", None)
or getattr(res, "target", None)
or "",
getattr(res,
"path",
None) or getattr(res,
"url",
None) or getattr(res,
"target",
None) or "",
)
self.current_result_table = table
@@ -259,7 +287,8 @@ class SearchModal(ModalScreen):
tags_text = self.tags_textarea.text if self.tags_textarea else ""
# Get library source (if OpenLibrary)
library_source = (
self.library_source_select.value if self.library_source_select else "local"
self.library_source_select.value
if self.library_source_select else "local"
)
# Add tags and source to result
@@ -301,9 +330,11 @@ class SearchModal(ModalScreen):
if source == "openlibrary":
# For OpenLibrary: title, author, year
author = (
", ".join(metadata.get("authors", []))
if isinstance(metadata.get("authors"), list)
else metadata.get("authors", "")
", ".join(metadata.get("authors",
[]))
if isinstance(metadata.get("authors"),
list) else metadata.get("authors",
"")
)
year = str(metadata.get("year", ""))
tags = []
@@ -337,7 +368,9 @@ class SearchModal(ModalScreen):
async def _download_book(self, result: Any) -> None:
"""Download a book from OpenLibrary using the provider."""
if getattr(result, "table", "") != "openlibrary":
logger.warning("[search-modal] Download only supported for OpenLibrary results")
logger.warning(
"[search-modal] Download only supported for OpenLibrary results"
)
return
try:
@@ -378,7 +411,9 @@ class SearchModal(ModalScreen):
f"[search-modal] Ctrl+T: Populated tags from result at row {selected_row}"
)
else:
logger.warning(f"[search-modal] Ctrl+T: Invalid row index {selected_row}")
logger.warning(
f"[search-modal] Ctrl+T: Invalid row index {selected_row}"
)
except Exception as e:
logger.error(f"[search-modal] Ctrl+T error: {e}")
else: