f
This commit is contained in:
@@ -7,7 +7,7 @@ import sys
|
||||
from contextlib import contextmanager
|
||||
from dataclasses import dataclass, field
|
||||
from contextvars import ContextVar
|
||||
from typing import Any, Dict, List, Optional, Sequence
|
||||
from typing import Any, Dict, List, Optional, Sequence, Callable
|
||||
from SYS.models import PipelineStageContext
|
||||
from SYS.logger import log, debug, is_debug_enabled
|
||||
from SYS.worker import WorkerManagerRegistry, WorkerStages
|
||||
@@ -15,6 +15,9 @@ from SYS.cli_parsing import SelectionSyntax, SelectionFilterSyntax
|
||||
from SYS.rich_display import stdout_console
|
||||
from SYS.background_notifier import ensure_background_notifier
|
||||
from SYS.result_table import Table
|
||||
import re
|
||||
from datetime import datetime
|
||||
from SYS.cmdlet_catalog import import_cmd_module
|
||||
|
||||
HELP_EXAMPLE_SOURCE_COMMANDS = {
|
||||
".help-example",
|
||||
@@ -946,8 +949,9 @@ def get_last_result_table_source_command() -> Optional[str]:
|
||||
Command name (e.g., 'download-file') or None if not set
|
||||
"""
|
||||
state = _get_pipeline_state()
|
||||
if _is_selectable_table(state.last_result_table) and hasattr(state.last_result_table, "source_command"):
|
||||
return state.last_result_table.source_command
|
||||
table = state.last_result_table
|
||||
if table is not None and _is_selectable_table(table) and hasattr(table, "source_command"):
|
||||
return getattr(table, "source_command")
|
||||
return None
|
||||
|
||||
|
||||
@@ -958,8 +962,9 @@ def get_last_result_table_source_args() -> List[str]:
|
||||
List of arguments (e.g., ['https://example.com']) or empty list
|
||||
"""
|
||||
state = _get_pipeline_state()
|
||||
if _is_selectable_table(state.last_result_table) and hasattr(state.last_result_table, "source_args"):
|
||||
return state.last_result_table.source_args or []
|
||||
table = state.last_result_table
|
||||
if table is not None and _is_selectable_table(table) and hasattr(table, "source_args"):
|
||||
return getattr(table, "source_args") or []
|
||||
return []
|
||||
|
||||
|
||||
@@ -973,22 +978,26 @@ def get_last_result_table_row_selection_args(row_index: int) -> Optional[List[st
|
||||
Selection arguments (e.g., ['-item', '3']) or None
|
||||
"""
|
||||
state = _get_pipeline_state()
|
||||
if _is_selectable_table(state.last_result_table) and hasattr(state.last_result_table, "rows"):
|
||||
if 0 <= row_index < len(state.last_result_table.rows):
|
||||
row = state.last_result_table.rows[row_index]
|
||||
table = state.last_result_table
|
||||
if table is not None and _is_selectable_table(table) and hasattr(table, "rows"):
|
||||
rows = table.rows
|
||||
if 0 <= row_index < len(rows):
|
||||
row = rows[row_index]
|
||||
if hasattr(row, "selection_args"):
|
||||
return row.selection_args
|
||||
return getattr(row, "selection_args")
|
||||
return None
|
||||
|
||||
|
||||
def get_last_result_table_row_selection_action(row_index: int) -> Optional[List[str]]:
|
||||
"""Get the expanded stage tokens for a row in the last result table."""
|
||||
state = _get_pipeline_state()
|
||||
if _is_selectable_table(state.last_result_table) and hasattr(state.last_result_table, "rows"):
|
||||
if 0 <= row_index < len(state.last_result_table.rows):
|
||||
row = state.last_result_table.rows[row_index]
|
||||
table = state.last_result_table
|
||||
if table is not None and _is_selectable_table(table) and hasattr(table, "rows"):
|
||||
rows = table.rows
|
||||
if 0 <= row_index < len(rows):
|
||||
row = rows[row_index]
|
||||
if hasattr(row, "selection_action"):
|
||||
return row.selection_action
|
||||
return getattr(row, "selection_action")
|
||||
return None
|
||||
|
||||
def set_current_stage_table(result_table: Optional[Any]) -> None:
|
||||
@@ -1019,8 +1028,9 @@ def get_current_stage_table_source_command() -> Optional[str]:
|
||||
Command name (e.g., 'download-file') or None
|
||||
"""
|
||||
state = _get_pipeline_state()
|
||||
if _is_selectable_table(state.current_stage_table) and hasattr(state.current_stage_table, "source_command"):
|
||||
return state.current_stage_table.source_command
|
||||
table = state.current_stage_table
|
||||
if table is not None and _is_selectable_table(table) and hasattr(table, "source_command"):
|
||||
return getattr(table, "source_command")
|
||||
return None
|
||||
|
||||
|
||||
@@ -1031,8 +1041,9 @@ def get_current_stage_table_source_args() -> List[str]:
|
||||
List of arguments or empty list
|
||||
"""
|
||||
state = _get_pipeline_state()
|
||||
if _is_selectable_table(state.current_stage_table) and hasattr(state.current_stage_table, "source_args"):
|
||||
return state.current_stage_table.source_args or []
|
||||
table = state.current_stage_table
|
||||
if table is not None and _is_selectable_table(table) and hasattr(table, "source_args"):
|
||||
return getattr(table, "source_args") or []
|
||||
return []
|
||||
|
||||
|
||||
@@ -1046,22 +1057,26 @@ def get_current_stage_table_row_selection_args(row_index: int) -> Optional[List[
|
||||
Selection arguments or None
|
||||
"""
|
||||
state = _get_pipeline_state()
|
||||
if _is_selectable_table(state.current_stage_table) and hasattr(state.current_stage_table, "rows"):
|
||||
if 0 <= row_index < len(state.current_stage_table.rows):
|
||||
row = state.current_stage_table.rows[row_index]
|
||||
table = state.current_stage_table
|
||||
if table is not None and _is_selectable_table(table) and hasattr(table, "rows"):
|
||||
rows = table.rows
|
||||
if 0 <= row_index < len(rows):
|
||||
row = rows[row_index]
|
||||
if hasattr(row, "selection_args"):
|
||||
return row.selection_args
|
||||
return getattr(row, "selection_args")
|
||||
return None
|
||||
|
||||
|
||||
def get_current_stage_table_row_selection_action(row_index: int) -> Optional[List[str]]:
|
||||
"""Get the expanded stage tokens for a row in the current stage table."""
|
||||
state = _get_pipeline_state()
|
||||
if _is_selectable_table(state.current_stage_table) and hasattr(state.current_stage_table, "rows"):
|
||||
if 0 <= row_index < len(state.current_stage_table.rows):
|
||||
row = state.current_stage_table.rows[row_index]
|
||||
table = state.current_stage_table
|
||||
if table is not None and _is_selectable_table(table) and hasattr(table, "rows"):
|
||||
rows = table.rows
|
||||
if 0 <= row_index < len(rows):
|
||||
row = rows[row_index]
|
||||
if hasattr(row, "selection_action"):
|
||||
return row.selection_action
|
||||
return getattr(row, "selection_action")
|
||||
return None
|
||||
|
||||
|
||||
@@ -1072,9 +1087,11 @@ def get_current_stage_table_row_source_index(row_index: int) -> Optional[int]:
|
||||
back to the original item order (e.g., playlist or provider order).
|
||||
"""
|
||||
state = _get_pipeline_state()
|
||||
if _is_selectable_table(state.current_stage_table) and hasattr(state.current_stage_table, "rows"):
|
||||
if 0 <= row_index < len(state.current_stage_table.rows):
|
||||
row = state.current_stage_table.rows[row_index]
|
||||
table = state.current_stage_table
|
||||
if table is not None and _is_selectable_table(table) and hasattr(table, "rows"):
|
||||
rows = table.rows
|
||||
if 0 <= row_index < len(rows):
|
||||
row = rows[row_index]
|
||||
return getattr(row, "source_index", None)
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user