cmdlet refactor
This commit is contained in:
@@ -636,6 +636,21 @@ class Provider(ABC):
|
||||
"""True if tag writes should be deferred until after file ingest."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def supports_url_association(self) -> bool:
|
||||
"""True when this provider supports associating URLs to files."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def supports_note_association(self) -> bool:
|
||||
"""True when this provider supports per-file named notes."""
|
||||
return False
|
||||
|
||||
@property
|
||||
def supports_relationship_association(self) -> bool:
|
||||
"""True when this provider supports file relationship links (king/alt/related)."""
|
||||
return False
|
||||
|
||||
def add_file(self, file_path: Path, **kwargs: Any) -> str:
|
||||
"""Ingest a file and return its canonical hash."""
|
||||
raise NotImplementedError(f"Plugin '{self.name}' does not support add_file")
|
||||
|
||||
@@ -471,7 +471,7 @@ class PluginRegistry:
|
||||
if not info.is_multi_instance:
|
||||
continue
|
||||
if not info.supported_cmdlets.intersection(
|
||||
{"add-file", "get-file", "get-tag", "add-tag"}
|
||||
{"add-file", "get-file", "tag"}
|
||||
):
|
||||
continue
|
||||
try:
|
||||
@@ -544,6 +544,9 @@ def get_plugin_capabilities(
|
||||
"supports_upload": False,
|
||||
"supports_pipe_download": False,
|
||||
"supports_delete_file": False,
|
||||
"supports_url_association": False,
|
||||
"supports_note_association": False,
|
||||
"supports_relationship_association": False,
|
||||
"is_multi_instance": False,
|
||||
"configured_instances": [],
|
||||
}
|
||||
@@ -559,11 +562,20 @@ def get_plugin_capabilities(
|
||||
supports_delete_file = callable(delete_method) and delete_method is not base_delete_method
|
||||
|
||||
configured_instances: List[str] = []
|
||||
supports_url_association = False
|
||||
supports_note_association = False
|
||||
supports_relationship_association = False
|
||||
try:
|
||||
plugin_obj = info.plugin_class(config or {})
|
||||
configured_instances = [str(v) for v in (plugin_obj.configured_instances() or []) if str(v).strip()]
|
||||
supports_url_association = bool(getattr(plugin_obj, "supports_url_association", False))
|
||||
supports_note_association = bool(getattr(plugin_obj, "supports_note_association", False))
|
||||
supports_relationship_association = bool(getattr(plugin_obj, "supports_relationship_association", False))
|
||||
except Exception:
|
||||
configured_instances = []
|
||||
supports_url_association = False
|
||||
supports_note_association = False
|
||||
supports_relationship_association = False
|
||||
|
||||
return {
|
||||
"name": info.canonical_name,
|
||||
@@ -572,6 +584,9 @@ def get_plugin_capabilities(
|
||||
"supports_upload": bool(info.supports_upload),
|
||||
"supports_pipe_download": bool(supports_pipe_download),
|
||||
"supports_delete_file": bool(supports_delete_file),
|
||||
"supports_url_association": bool(supports_url_association),
|
||||
"supports_note_association": bool(supports_note_association),
|
||||
"supports_relationship_association": bool(supports_relationship_association),
|
||||
"is_multi_instance": bool(info.is_multi_instance),
|
||||
"configured_instances": configured_instances,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user