тест
Some checks failed
CI / Lint (ruff + mypy) (push) Failing after 31s
CI / Run tests (push) Has been skipped
CI / Docker build test (push) Successful in 10s

This commit is contained in:
2026-04-02 21:51:01 +07:00
parent 75f5d4cea4
commit 8be26418b1
2 changed files with 54 additions and 1 deletions

View File

@@ -43,6 +43,20 @@ def build_actor_line(actor: dict, state: dict, config: dict) -> str:
return line
def build_actor_fragment(actor: dict, state: dict, config: dict) -> str:
actor_state = state.get("actors", {})
status_labels = {**DEFAULT_STATUS_LABELS, **config.get("status_labels", {})}
current = actor_state.get(actor["key"], {})
status = current.get("status", actor.get("default_status", "backstage"))
phrase = current.get("phrase", actor.get("phrases", {}).get(status, ""))
label = status_labels.get(status, status)
fragment = f"{escape(label)}."
if phrase:
fragment = f"{fragment}\n {escape(phrase)}"
return fragment
def build_actor_lines(config: dict, state: dict, skip_keys: set[str] | None = None) -> str:
actor_lines: list[str] = []
skip_keys = skip_keys or set()
@@ -66,7 +80,17 @@ def replace_actor_placeholders(template: str, config: dict, state: dict) -> tupl
if actor is None:
return match.group(0)
used_keys.add(actor["key"])
return build_actor_line(actor, state, config)
line_start = template.rfind("\n", 0, match.start()) + 1
line_end = template.find("\n", match.end())
if line_end == -1:
line_end = len(template)
line_text = template[line_start:line_end]
if line_text.strip().lower() == match.group(0).strip().lower():
return build_actor_line(actor, state, config)
return build_actor_fragment(actor, state, config)
return ACTOR_PLACEHOLDER_RE.sub(repl, template), used_keys