cleanup and rename provider to plugin

This commit is contained in:
2026-05-21 16:19:17 -07:00
parent 02d84f423e
commit e8913d1344
62 changed files with 553 additions and 165 deletions
+2 -2
View File
@@ -88,7 +88,7 @@ def _load_root_modules() -> None:
def _load_helper_modules() -> None:
# Provider-specific module pre-loading removed; providers are loaded lazily
# through ProviderCore.registry when first referenced.
# through PluginCore.registry when first referenced.
#
# Keep explicit imports for cmdlets moved into subpackages so they remain
# registered under their legacy command names.
@@ -118,7 +118,7 @@ def _register_native_commands() -> None:
def _register_plugin_commands() -> None:
try:
from ProviderCore.commands import register_plugin_commands
from PluginCore.commands import register_plugin_commands
except Exception:
return
try:
+3 -3
View File
@@ -276,7 +276,7 @@ class SharedArgs:
# Plugin-based multi-instance backends (config["plugin"] / config["provider"] sections)
try:
from ProviderCore.registry import REGISTRY
from PluginCore.registry import REGISTRY
plugin_instances = REGISTRY.list_storage_plugin_instances(config)
for _plugin_name, instance_names in plugin_instances.items():
names.update(instance_names)
@@ -1448,7 +1448,7 @@ def fetch_hydrus_metadata(
client = hydrus_client
hydrus_provider = None
try:
from ProviderCore.registry import get_plugin
from PluginCore.registry import get_plugin
hydrus_provider = get_plugin("hydrusnetwork", config)
except Exception:
@@ -4177,7 +4177,7 @@ def check_url_exists_in_storage(
hydrus_provider = None
try:
from ProviderCore.registry import get_plugin
from PluginCore.registry import get_plugin
hydrus_provider = get_plugin("hydrusnetwork", config)
except Exception:
+3 -3
View File
@@ -63,7 +63,7 @@ class _CommandDependencies:
def get_plugin(self, name: str) -> Optional[Any]:
"""Cached plugin lookup by name."""
from ProviderCore.registry import get_plugin
from PluginCore.registry import get_plugin
norm_name = str(name or "").strip().lower()
if not norm_name:
@@ -77,7 +77,7 @@ class _CommandDependencies:
def get_plugin_with_capability(self, name: str, capability: str) -> Optional[Any]:
"""Cached plugin lookup with capability check."""
from ProviderCore.registry import get_plugin_with_capability
from PluginCore.registry import get_plugin_with_capability
norm_name = str(name or "").strip().lower()
if not norm_name:
@@ -2336,7 +2336,7 @@ class Add_File(Cmdlet):
delete_after: bool,
) -> int:
"""Handle uploading via an upload plugin (e.g. 0x0)."""
from ProviderCore.registry import (
from PluginCore.registry import (
get_plugin_with_capability,
list_plugin_names_with_capability,
list_plugins_with_capability,
+1 -1
View File
@@ -13,7 +13,7 @@ from typing import Any, Dict, List, Sequence, Set
from urllib.parse import parse_qs, urlparse
from SYS.logger import log
from ProviderCore.registry import get_plugin
from PluginCore.registry import get_plugin
from SYS.item_accessors import get_http_url, get_sha256_hex, get_store_name
from SYS.utils import extract_hydrus_hash_from_url
+1 -1
View File
@@ -8,7 +8,7 @@ import sys
from pathlib import Path
from SYS.logger import debug, log
from ProviderCore.registry import get_plugin
from PluginCore.registry import get_plugin
from Store import Store
from .. import _shared as sh
from SYS import pipeline as ctx
+2 -2
View File
@@ -992,8 +992,8 @@ class Download_File(Cmdlet):
def _load_provider_registry() -> Dict[str, Any]:
"""Lightweight accessor for plugin helpers without hard dependencies."""
try:
from ProviderCore import registry as provider_registry # type: ignore
from ProviderCore.base import SearchResult # type: ignore
from PluginCore import registry as provider_registry # type: ignore
from PluginCore.base import SearchResult # type: ignore
return {
"get_plugin": getattr(provider_registry, "get_plugin", None),
+1 -1
View File
@@ -154,7 +154,7 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
if urls_to_download and len(urls_to_download) >= 2:
try:
from ProviderCore.registry import get_plugin_for_url
from PluginCore.registry import get_plugin_for_url
expanded: List[Dict[str, Any]] = []
downloaded_any = False
+1 -1
View File
@@ -15,7 +15,7 @@ from urllib.parse import urlparse, parse_qs, unquote, urljoin
from SYS.logger import log, debug, debug_panel
from SYS.payload_builders import build_file_result_payload, normalize_file_extension
from ProviderCore.registry import get_plugin_with_capability, list_plugins_with_capability
from PluginCore.registry import get_plugin_with_capability, list_plugins_with_capability
from SYS.rich_display import (
show_plugin_config_panel,
show_store_config_panel,
+1 -1
View File
@@ -5,7 +5,7 @@ import sys
from SYS.detail_view_helpers import create_detail_view, prepare_detail_metadata
from SYS.logger import log
from ProviderCore.registry import get_plugin
from PluginCore.registry import get_plugin
from SYS.result_table_helpers import add_row_columns
from SYS.selection_builder import build_hash_store_selection
from SYS.result_publication import publish_result_table
+1 -1
View File
@@ -9,7 +9,7 @@ import sys
from SYS.logger import log
from SYS.item_accessors import get_sha256_hex, get_store_name
from ProviderCore.registry import get_plugin
from PluginCore.registry import get_plugin
from SYS import pipeline as ctx
from .. import _shared as sh
+8 -8
View File
@@ -14,18 +14,18 @@ import sys
from SYS.logger import log, debug
# plugins.metadata_provider is deferred: it transitively loads yt_dlp, Cryptodome,
# plugins.metadata_plugin is deferred: it transitively loads yt_dlp, Cryptodome,
# imdbinfo, musicbrainzngs and ~1400 modules (~1.5s). Import lazily on first use.
_METADATA_PROVIDER_MOD: Optional[Any] = None
_METADATA_PLUGIN_MOD: Optional[Any] = None
def _mp() -> Any:
"""Return the (lazily imported) plugins.metadata_provider module."""
global _METADATA_PROVIDER_MOD
if _METADATA_PROVIDER_MOD is None:
import plugins.metadata_provider as _m
_METADATA_PROVIDER_MOD = _m
return _METADATA_PROVIDER_MOD
"""Return the (lazily imported) plugins.metadata_plugin module."""
global _METADATA_PLUGIN_MOD
if _METADATA_PLUGIN_MOD is None:
import plugins.metadata_plugin as _m
_METADATA_PLUGIN_MOD = _m
return _METADATA_PLUGIN_MOD
from pathlib import Path
@@ -42,7 +42,7 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
select_raw = parsed.get("select")
try:
provider = get_plugin(plugin_name)
plugin = get_plugin(plugin_name)
except Exception:
log(f"Unknown plugin: {plugin_name}", file=sys.stderr)
return 1
@@ -52,7 +52,7 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
if use_sample:
# Try to locate SAMPLE_ITEMS in the adapter's module (convention only)
try:
mod = __import__(provider.adapter.__module__, fromlist=["*"])
mod = __import__(plugin.adapter.__module__, fromlist=["*"])
items = getattr(mod, "SAMPLE_ITEMS", None)
if items is None:
log("Plugin does not expose SAMPLE_ITEMS; no sample available", file=sys.stderr)
@@ -69,14 +69,14 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
items = inputs
try:
table = provider.build_table(items)
table = plugin.build_table(items)
except Exception as exc:
log(f"Plugin '{provider.name}' failed: {exc}", file=sys.stderr)
log(f"Plugin '{plugin.name}' failed: {exc}", file=sys.stderr)
return 1
# Emit rows for downstream pipeline consumption (pipable behavior).
try:
for item in provider.serialize_rows(table.rows):
for item in plugin.serialize_rows(table.rows):
try:
ctx.emit(item)
except Exception:
@@ -115,7 +115,7 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
return 1
selected = table.rows[select_idx]
sel_args = provider.selection_args(selected)
sel_args = plugin.selection_args(selected)
if not run_cmd:
# Print selection args for caller