Files
Medios-Macina/cmdlet/delete_relationship.py

61 lines
1.8 KiB
Python
Raw Normal View History

2026-01-22 03:12:16 -08:00
"""Delete file relationships (Currently Disabled)."""
2025-12-03 15:18:57 -08:00
import sys
2026-01-22 03:12:16 -08:00
from typing import Any, Dict, List, Optional
2025-12-03 15:18:57 -08:00
from SYS import pipeline as ctx
2025-12-16 23:23:43 -08:00
from . import _shared as sh
normalize_hash = sh.normalize_hash
get_field = sh.get_field
2025-12-03 15:18:57 -08:00
2025-12-16 01:45:01 -08:00
def _extract_hash(item: Any) -> Optional[str]:
h = get_field(item,
"hash_hex") or get_field(item,
"hash") or get_field(item,
"file_hash")
2025-12-16 01:45:01 -08:00
return normalize_hash(str(h)) if h else None
2026-01-22 03:12:16 -08:00
def _run(args: List[str], config: Dict[str, Any]) -> int:
2025-12-03 15:18:57 -08:00
try:
2026-01-22 03:12:16 -08:00
parsed, _, _ = sh.parse_cmdlet_args(args)
if sh.should_show_help(parsed):
2025-12-12 21:55:38 -08:00
return 0
2026-01-22 03:12:16 -08:00
# Relationship deletion is currently not implemented for Hydrus.
# Legacy Folder storage has been removed.
sh.log("Relationship deletion is currently only supported via Folder storage, which has been removed.", file=sys.stderr)
sh.log("Hydrus relationship management via Medios-Macina is planned for a future update.", file=sys.stderr)
return 1
2025-12-29 17:05:03 -08:00
2025-12-03 15:18:57 -08:00
except Exception as exc:
2026-01-22 03:12:16 -08:00
sh.log(f"Error in delete-relationship: {exc}", file=sys.stderr)
2025-12-03 15:18:57 -08:00
return 1
2026-01-22 03:12:16 -08:00
CMDLET = sh.Cmdlet(
2025-12-03 15:18:57 -08:00
name="delete-relationship",
2026-01-22 03:12:16 -08:00
summary="Remove relationships from files (Currently Disabled).",
usage="@1 | delete-relationship --all",
2025-12-11 12:47:30 -08:00
arg=[
2026-01-22 03:12:16 -08:00
sh.SharedArgs.PATH,
sh.SharedArgs.STORE,
sh.SharedArgs.QUERY,
sh.CmdletArg(
"all",
type="flag",
description="Delete all relationships for the file(s)."
),
2026-01-22 03:12:16 -08:00
sh.CmdletArg(
2025-12-29 17:05:03 -08:00
"type",
type="string",
2026-01-22 03:12:16 -08:00
description="Delete specific relationship type.",
2025-12-29 17:05:03 -08:00
),
2025-12-03 15:18:57 -08:00
],
)
2025-12-12 21:55:38 -08:00
CMDLET.exec = _run
CMDLET.register()