cleanup and rename provider to plugin
This commit is contained in:
@@ -6,8 +6,8 @@ from pathlib import Path
|
||||
from types import ModuleType
|
||||
from typing import Any, Dict, List, Optional
|
||||
import logging
|
||||
from ProviderCore.commands import get_primary_command_object
|
||||
from ProviderCore.registry import get_plugin
|
||||
from PluginCore.commands import get_primary_command_object
|
||||
from PluginCore.registry import get_plugin
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
|
||||
+1
-1
@@ -279,7 +279,7 @@ def extract_records(doc_or_html: Any, base_url: Optional[str] = None, xpaths: Op
|
||||
|
||||
# Small convenience: convert records to SearchResult. Providers can call this or
|
||||
# use their own mapping when they need full SearchResult objects.
|
||||
from ProviderCore.base import SearchResult # local import to avoid circular issues
|
||||
from PluginCore.base import SearchResult # local import to avoid circular issues
|
||||
|
||||
|
||||
def records_to_search_results(records: List[Dict[str, str]], table: str = "provider") -> List[SearchResult]:
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ logger = logging.getLogger(__name__)
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Iterable, List, Optional, Sequence, Set, Tuple
|
||||
|
||||
from ProviderCore.registry import get_plugin
|
||||
from PluginCore.registry import get_plugin
|
||||
from SYS.yt_metadata import extract_ytdlp_tags
|
||||
|
||||
try: # Optional; used when available for richer metadata fetches
|
||||
|
||||
+4
-4
@@ -1562,7 +1562,7 @@ class PipelineExecutor:
|
||||
_add(getattr(item, "table", None))
|
||||
|
||||
try:
|
||||
from ProviderCore.registry import get_plugin, is_known_plugin_name
|
||||
from PluginCore.registry import get_plugin, is_known_plugin_name
|
||||
except Exception:
|
||||
get_plugin = None # type: ignore
|
||||
is_known_plugin_name = None # type: ignore
|
||||
@@ -1679,7 +1679,7 @@ class PipelineExecutor:
|
||||
_add(getattr(item, "source", None))
|
||||
|
||||
try:
|
||||
from ProviderCore.registry import get_plugin, is_known_plugin_name
|
||||
from PluginCore.registry import get_plugin, is_known_plugin_name
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
@@ -2313,7 +2313,7 @@ class PipelineExecutor:
|
||||
auto_stage = None
|
||||
if isinstance(table_type, str) and table_type:
|
||||
try:
|
||||
from ProviderCore.registry import selection_auto_stage_for_table
|
||||
from PluginCore.registry import selection_auto_stage_for_table
|
||||
|
||||
auto_stage = selection_auto_stage_for_table(table_type)
|
||||
except Exception:
|
||||
@@ -3098,7 +3098,7 @@ class PipelineExecutor:
|
||||
auto_stage = None
|
||||
if isinstance(table_type, str) and table_type:
|
||||
try:
|
||||
from ProviderCore.registry import selection_auto_stage_for_table
|
||||
from PluginCore.registry import selection_auto_stage_for_table
|
||||
|
||||
# Preserve historical behavior: only forward selection-stage args
|
||||
# to the auto stage when we are appending a new last stage.
|
||||
|
||||
@@ -6,7 +6,7 @@ import pkgutil
|
||||
from typing import Any, Dict, Iterable, List, Optional
|
||||
|
||||
from SYS.config import global_config
|
||||
from ProviderCore.registry import get_plugin_class, list_plugins
|
||||
from PluginCore.registry import get_plugin_class, list_plugins
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -194,7 +194,7 @@ def get_required_config_keys(item_type: str, item_name: str) -> List[str]:
|
||||
|
||||
def get_configurable_store_types() -> List[str]:
|
||||
"""Return configurable multi-instance plugin types (formerly 'store types')."""
|
||||
from ProviderCore.registry import REGISTRY
|
||||
from PluginCore.registry import REGISTRY
|
||||
options: List[str] = []
|
||||
for info in REGISTRY.iter_plugins():
|
||||
plugin_cls = info.plugin_class
|
||||
@@ -205,7 +205,7 @@ def get_configurable_store_types() -> List[str]:
|
||||
|
||||
def get_configurable_plugin_types() -> List[str]:
|
||||
"""Return all plugin types that can be configured: those with a schema or MULTI_INSTANCE flag."""
|
||||
from ProviderCore.registry import REGISTRY
|
||||
from PluginCore.registry import REGISTRY
|
||||
options: List[str] = []
|
||||
for info in REGISTRY.iter_plugins():
|
||||
plugin_cls = info.plugin_class
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
"""Convenience mixins and helpers for table-based providers.
|
||||
"""Convenience mixins and helpers for table-based plugins.
|
||||
|
||||
Provides a small `TableProviderMixin` that handles HTTP fetch + table extraction
|
||||
Provides a small `TablePluginMixin` that handles HTTP fetch + table extraction
|
||||
(using `SYS.html_table.extract_records`) and converts records into
|
||||
`ProviderCore.base.SearchResult` rows with sane default column ordering.
|
||||
`PluginCore.base.SearchResult` rows with sane default column ordering.
|
||||
|
||||
Providers can subclass this mixin to implement search quickly:
|
||||
Plugins can subclass this mixin to implement search quickly:
|
||||
|
||||
class MyProvider(TableProviderMixin, Provider):
|
||||
class MyPlugin(TablePluginMixin, Provider):
|
||||
URL = ("https://example.org/search",)
|
||||
|
||||
def search(self, query, limit=50, **kwargs):
|
||||
@@ -21,7 +21,7 @@ from __future__ import annotations
|
||||
from typing import List, Optional
|
||||
|
||||
from API.HTTP import HTTPClient
|
||||
from ProviderCore.base import SearchResult
|
||||
from PluginCore.base import SearchResult
|
||||
from SYS.html_table import extract_records
|
||||
import lxml.html as lxml_html
|
||||
|
||||
@@ -29,8 +29,8 @@ import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TableProviderMixin:
|
||||
"""Mixin to simplify providers that scrape table/list results from HTML.
|
||||
class TablePluginMixin:
|
||||
"""Mixin to simplify plugins that scrape table/list results from HTML.
|
||||
|
||||
Methods:
|
||||
- search_table_from_url(url, limit, xpaths): fetches HTML, extracts records, returns SearchResults
|
||||
@@ -59,7 +59,7 @@ class TableProviderMixin:
|
||||
resp = client.get(url)
|
||||
content = resp.content
|
||||
except Exception:
|
||||
logger.exception("Failed to fetch URL %s for provider %s", url, getattr(self, 'name', '<provider>'))
|
||||
logger.exception("Failed to fetch URL %s for plugin %s", url, getattr(self, 'name', '<plugin>'))
|
||||
return []
|
||||
|
||||
# Ensure we pass an lxml document or string (httpx returns bytes)
|
||||
@@ -99,14 +99,14 @@ class TableProviderMixin:
|
||||
|
||||
results.append(
|
||||
SearchResult(
|
||||
table=(getattr(self, "name", "provider") or "provider"),
|
||||
table=(getattr(self, "name", "plugin") or "plugin"),
|
||||
title=title,
|
||||
path=path,
|
||||
detail="",
|
||||
annotations=[],
|
||||
media_kind="file",
|
||||
size_bytes=None,
|
||||
tag={getattr(self, "name", "provider")},
|
||||
tag={getattr(self, "name", "plugin") or "plugin"},
|
||||
columns=cols,
|
||||
full_metadata={"raw_record": rec},
|
||||
)
|
||||
Reference in New Issue
Block a user