added repl injection
This commit is contained in:
@@ -1778,6 +1778,9 @@ class PipelineExecutor:
|
||||
return [str(x) for x in candidate if x is not None]
|
||||
return None
|
||||
|
||||
def _norm_cmd_name(value: Any) -> str:
|
||||
return str(value or "").replace("_", "-").strip().lower()
|
||||
|
||||
# ============================================================================
|
||||
# PHASE 2: Parse source command and table metadata
|
||||
# ============================================================================
|
||||
@@ -1841,11 +1844,23 @@ class PipelineExecutor:
|
||||
else:
|
||||
selected_row_args: List[str] = []
|
||||
skip_pipe_expansion = source_cmd in {".pipe", ".mpv"} and len(stages) > 0
|
||||
prefer_row_action = False
|
||||
if len(selection_indices) == 1 and not stages:
|
||||
try:
|
||||
row_action = _get_row_action(selection_indices[0])
|
||||
except Exception:
|
||||
row_action = None
|
||||
if row_action:
|
||||
prefer_row_action = True
|
||||
debug(
|
||||
"@N: skipping source command expansion because row has explicit selection_action "
|
||||
f"{row_action}"
|
||||
)
|
||||
# Command expansion via @N:
|
||||
# - Default behavior: expand ONLY for single-row selections.
|
||||
# - Special case: allow multi-row expansion for add-file directory tables by
|
||||
# combining selected rows into a single `-path file1,file2,...` argument.
|
||||
if source_cmd and not skip_pipe_expansion:
|
||||
if source_cmd and not skip_pipe_expansion and not prefer_row_action:
|
||||
src = str(source_cmd).replace("_", "-").strip().lower()
|
||||
|
||||
if src == "add-file" and selection_indices:
|
||||
@@ -2119,7 +2134,7 @@ class PipelineExecutor:
|
||||
source_args_for_selection = []
|
||||
|
||||
if not stages and selection_indices and source_cmd_for_selection:
|
||||
src_norm = _norm_cmd(source_cmd_for_selection)
|
||||
src_norm = _norm_cmd_name(source_cmd_for_selection)
|
||||
if src_norm in {".worker", "worker", "workers"}:
|
||||
if len(selection_indices) == 1:
|
||||
idx = selection_indices[0]
|
||||
@@ -2197,7 +2212,7 @@ class PipelineExecutor:
|
||||
logger.exception("Failed to record pipeline log step for applied row action (pipeline_session=%r)", getattr(pipeline_session, 'worker_id', None))
|
||||
else:
|
||||
first_cmd = stages[0][0] if stages and stages[0] else None
|
||||
first_cmd_norm = _norm_cmd(first_cmd)
|
||||
first_cmd_norm = _norm_cmd_name(first_cmd)
|
||||
|
||||
inserted_provider_download = False
|
||||
if first_cmd_norm == "add-file":
|
||||
@@ -2205,7 +2220,7 @@ class PipelineExecutor:
|
||||
# run download before add-file so add-file receives local files.
|
||||
if len(selection_indices) == 1:
|
||||
row_action = _get_row_action(selection_indices[0], items_list)
|
||||
if row_action and _norm_cmd(row_action[0]) == "download-file":
|
||||
if row_action and _norm_cmd_name(row_action[0]) == "download-file":
|
||||
stages.insert(0, [str(x) for x in row_action if x is not None])
|
||||
inserted_provider_download = True
|
||||
debug("Auto-inserting row download-file action before add-file")
|
||||
@@ -2218,7 +2233,7 @@ class PipelineExecutor:
|
||||
has_download_row_action = False
|
||||
for idx in selection_indices:
|
||||
row_action = _get_row_action(idx, items_list)
|
||||
if row_action and _norm_cmd(row_action[0]) == "download-file":
|
||||
if row_action and _norm_cmd_name(row_action[0]) == "download-file":
|
||||
has_download_row_action = True
|
||||
break
|
||||
if has_download_row_action:
|
||||
@@ -2237,8 +2252,8 @@ class PipelineExecutor:
|
||||
print("Auto-inserting get-tag after metadata selection")
|
||||
stages.insert(0, ["get-tag"])
|
||||
elif auto_stage:
|
||||
first_cmd_norm = _norm_cmd(stages[0][0] if stages and stages[0] else None)
|
||||
auto_cmd_norm = _norm_cmd(auto_stage[0])
|
||||
first_cmd_norm = _norm_cmd_name(stages[0][0] if stages and stages[0] else None)
|
||||
auto_cmd_norm = _norm_cmd_name(auto_stage[0])
|
||||
if first_cmd_norm not in (auto_cmd_norm, ".pipe", ".mpv"):
|
||||
debug(f"Auto-inserting {auto_cmd_norm} after selection")
|
||||
# Insert the auto stage before the user-specified stage
|
||||
|
||||
Reference in New Issue
Block a user