update CLI.py and SYS/cli_parsing.py to add new command line options for the pipeline. Also updated SYS/pipeline.py to handle the new options. Modified plugins/mpv/LUA/main.lua and plugins/mpv/portable_config/input.conf to reflect changes in the pipeline configuration.
This commit is contained in:
+13
-8
@@ -7,7 +7,7 @@ these pure helpers are easier to test.
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple
|
||||
from SYS.logger import debug
|
||||
|
||||
# Prompt-toolkit lexer types are optional and expensive (~300ms). Use find_spec
|
||||
@@ -66,13 +66,13 @@ DRIVE_RE = re.compile(r"^[A-Za-z]:[\\/]")
|
||||
|
||||
|
||||
class SelectionSyntax:
|
||||
"""Parses @ selection syntax into 1-based indices."""
|
||||
"""Parses @ selection syntax into ordered 1-based indices."""
|
||||
|
||||
_RANGE_RE = re.compile(r"^[0-9\-]+$")
|
||||
|
||||
@staticmethod
|
||||
def parse(token: str) -> Optional[Set[int]]:
|
||||
"""Return 1-based indices or None when not a concrete selection.
|
||||
def parse(token: str) -> Optional[List[int]]:
|
||||
"""Return ordered 1-based indices or None when not a concrete selection.
|
||||
|
||||
Concrete selections:
|
||||
- @2
|
||||
@@ -96,7 +96,8 @@ class SelectionSyntax:
|
||||
if selector.startswith("{") and selector.endswith("}"):
|
||||
selector = selector[1:-1].strip()
|
||||
|
||||
indices: Set[int] = set()
|
||||
indices: List[int] = []
|
||||
seen: set[int] = set()
|
||||
for part in selector.split(","):
|
||||
part = part.strip()
|
||||
if not part:
|
||||
@@ -117,7 +118,10 @@ class SelectionSyntax:
|
||||
return None
|
||||
if start <= 0 or end <= 0 or start > end:
|
||||
return None
|
||||
indices.update(range(start, end + 1))
|
||||
for value in range(start, end + 1):
|
||||
if value not in seen:
|
||||
seen.add(value)
|
||||
indices.append(value)
|
||||
continue
|
||||
|
||||
try:
|
||||
@@ -126,7 +130,9 @@ class SelectionSyntax:
|
||||
return None
|
||||
if value <= 0:
|
||||
return None
|
||||
indices.add(value)
|
||||
if value not in seen:
|
||||
seen.add(value)
|
||||
indices.append(value)
|
||||
|
||||
return indices if indices else None
|
||||
|
||||
@@ -498,4 +504,3 @@ class MedeiaLexer(Lexer):
|
||||
|
||||
return get_line
|
||||
|
||||
|
||||
|
||||
+2
-6
@@ -1452,9 +1452,7 @@ class PipelineExecutor:
|
||||
if token.startswith("@"): # selection
|
||||
selection = _cli_parsing().SelectionSyntax.parse(token)
|
||||
if selection is not None:
|
||||
first_stage_selection_indices = sorted(
|
||||
[i - 1 for i in selection]
|
||||
)
|
||||
first_stage_selection_indices = [i - 1 for i in selection]
|
||||
continue
|
||||
if token == "@*":
|
||||
first_stage_select_all = True
|
||||
@@ -2893,9 +2891,7 @@ class PipelineExecutor:
|
||||
if _cli_parsing().SelectionFilterSyntax.matches(item, filter_spec)
|
||||
]
|
||||
else:
|
||||
selected_indices = sorted(
|
||||
[i - 1 for i in selection]
|
||||
) # type: ignore[arg-type]
|
||||
selected_indices = [i - 1 for i in selection] # type: ignore[arg-type]
|
||||
|
||||
resolved_items = items_list if items_list else []
|
||||
filtered = [
|
||||
|
||||
Reference in New Issue
Block a user