codeplain 0.3.11.dev11__py3-none-any.whl → 0.3.11.dev13__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codeplain-0.3.11.dev11.dist-info → codeplain-0.3.11.dev13.dist-info}/METADATA +1 -1
- {codeplain-0.3.11.dev11.dist-info → codeplain-0.3.11.dev13.dist-info}/RECORD +11 -8
- git_preflight.py +41 -0
- plain_modules.py +6 -6
- tests/test_git_preflight.py +98 -0
- tests/test_tui_components.py +88 -0
- tui/components.py +13 -9
- tui/widget_helpers.py +11 -4
- {codeplain-0.3.11.dev11.dist-info → codeplain-0.3.11.dev13.dist-info}/WHEEL +0 -0
- {codeplain-0.3.11.dev11.dist-info → codeplain-0.3.11.dev13.dist-info}/entry_points.txt +0 -0
- {codeplain-0.3.11.dev11.dist-info → codeplain-0.3.11.dev13.dist-info}/licenses/LICENSE +0 -0
|
@@ -5,6 +5,7 @@ conformance_fix_journal.py,sha256=7wL3UOc3BWaUo5MCmiFbb3kIwOQ6iEpdQSyEmedo8Vk,94
|
|
|
5
5
|
diff_utils.py,sha256=AjiQlqo5pRos_8hVXZo5yBurl5BzSrTMGrQv4dCtRCg,1198
|
|
6
6
|
event_bus.py,sha256=g5XLwRfjrvTIcB6urjREuCJzZj5TA93hy8lKXLGXuCE,650
|
|
7
7
|
file_utils.py,sha256=MNZ5li1ofIMOYB6FCrMa_UkX6nkGCgSZuaqzhqVc1Ok,11682
|
|
8
|
+
git_preflight.py,sha256=vB2A8GyYz_iWr8jOE4POFLBHr3qihmedWuidspGdsrw,1509
|
|
8
9
|
git_utils.py,sha256=gCUA6_9zg19f6k_0aVcRnIVlAJSBD0Vt6takx-0pKME,16547
|
|
9
10
|
memory_management.py,sha256=CwIOQqF7Xo1sNfvP69zQRK_CpjinQD9dbolhRPl6lTk,2446
|
|
10
11
|
metadata_utils.py,sha256=YO17o7IAma5TT1ZN0pTwrLVr_KxFQ8APv02KqKPpI5k,1641
|
|
@@ -23,7 +24,7 @@ plain2code_state.py,sha256=uePQlC29Pbhm1yXfdCFebONYdy6jo13gTTmXSwC11cQ,3168
|
|
|
23
24
|
plain2code_telemetry.py,sha256=e4UCAoFklJMDWGQsL50i7nTLiOBy8gs86A0XO4WLgPo,4597
|
|
24
25
|
plain2code_utils.py,sha256=unOxuqSQRpwG8YF6uoQhnZ3ZSTJRIUCPLdJ-1lRZR5M,1534
|
|
25
26
|
plain_file.py,sha256=Kn8m_w6c04_RR-FBjAU05UcLOTDk4zcctpJXghYdZ8I,35757
|
|
26
|
-
plain_modules.py,sha256=
|
|
27
|
+
plain_modules.py,sha256=nXlmw0J2rKkuU1Y3A68LVtZ1Ffdc-D5iMjxaXSaSHTQ,25963
|
|
27
28
|
plain_spec.py,sha256=7nb5lLJKHZ3uu9THkSXyJ5brIKkbGW0ooVfRclLdlzA,16062
|
|
28
29
|
system_config.py,sha256=sA8wiPmBMtRsLwSQ40U5pVdLazAafbV-1Z19Yp0HiSQ,5314
|
|
29
30
|
usage_summary.py,sha256=MA4WcVaAwz6IWCN4k_rgxVcwO4I157wN7BZlFi3h0R4,1282
|
|
@@ -79,6 +80,7 @@ tests/test_dry_run_link_validation.py,sha256=ivvYXQPqUkQ8glbFyUrdCninCxF2mg-rAsD
|
|
|
79
80
|
tests/test_file_utils.py,sha256=R_ZIhrTtwlhHxgmbBtA8PFEU5-QB4Fi5skJ7PS2KzdU,3614
|
|
80
81
|
tests/test_fix_unit_tests_conformance_context.py,sha256=IEsXK0xMLRuHmoQGBwrY0ENWVng2n-db_YzSO2qBfqM,9136
|
|
81
82
|
tests/test_folder_path_resolution.py,sha256=K9v684xkPE0HOAsovg8uDixpZmaIk7ho-Wd3rTjKLF0,6560
|
|
83
|
+
tests/test_git_preflight.py,sha256=6aQqInDzpk03pS-6UfkGQWjErrIXTEdHs5oeq3ZYzTw,3186
|
|
82
84
|
tests/test_git_utils.py,sha256=h3rWhhs4XVRYqzVzdmj51siF_AYD-GkbZiefK2iGfWo,15614
|
|
83
85
|
tests/test_headless_logging.py,sha256=soNESeotKQaU-SQyxtjpq35l-dLVsauZ_lJ-wk9i2mI,6419
|
|
84
86
|
tests/test_imports.py,sha256=1ncbqQhtQW237kIjyV-Ufl7-R-PuduvoYFj2iS-DXW4,2608
|
|
@@ -99,22 +101,23 @@ tests/test_resolve_config_file.py,sha256=b87tDOvyzbsnE-QRWbZ97ou7NuyaAgskv-dbYBu
|
|
|
99
101
|
tests/test_script_path_resolution.py,sha256=tiEqMevQRXr9YpfHN0xldOOQpLAUgnSqTzeZWkKHaUY,4156
|
|
100
102
|
tests/test_system_config.py,sha256=gH5qs9q4lh5CljAdz28HUrJzuKqCvkZherFuv7enMak,2787
|
|
101
103
|
tests/test_telemetry.py,sha256=LINvx1_Oz1OJ3ho2RcIcAA29IsNfUbkVVCbFaQcrBaA,8133
|
|
104
|
+
tests/test_tui_components.py,sha256=a8MMZmJNU4EcT1GoOAGkb2gObK0h2AQvufbPCkTMkJk,3715
|
|
102
105
|
tests/test_tui_usage.py,sha256=sfiAGTpRrT3MRr0-8DH3qjuECSxjODVgwzrK_K3iPXs,7959
|
|
103
106
|
tests/test_usage_summary.py,sha256=Ps0kVzvmdZYeXrBR-cqkn3szTV5neYKs1PmmURngeIc,1079
|
|
104
107
|
tests/e2e/conftest.py,sha256=5Dm67UTOE-M6hMb-mqZvwa6Ek_wmZgsR7fUv9ZEqCwY,4164
|
|
105
108
|
tests/e2e/test_hello_world_python.py,sha256=2Cgs3-79dtQh5gVab257tFDHXTznefZeYqbTjlM4Nng,1632
|
|
106
109
|
tests/e2e/test_hello_world_python_windows.py,sha256=ggynH_Wm4011M500zoPNNgvD-s4vZ3hvlorf1yARgQQ,2019
|
|
107
110
|
tui/__init__.py,sha256=_fy7FowY0RkWdn4kC7XV2jgvQPCj-2gE8fNUb-Mny0A,60
|
|
108
|
-
tui/components.py,sha256=
|
|
111
|
+
tui/components.py,sha256=eU0t2s5SFfTAjjCYpvh9c9eakpWFJwodBKkiFwz15DU,26200
|
|
109
112
|
tui/models.py,sha256=KMjlWubmPD41GA-BjgiqkaV9v7tLJ0fuWKBDPmZj4JA,1493
|
|
110
113
|
tui/plain2code_tui.py,sha256=8F7ZYRpmTiWRdTeQ63LPf2LGrreYjIYXvf_9XNSPyHs,17104
|
|
111
114
|
tui/plain_module_render_choice_tui.py,sha256=XwBMMzyDat9FYqMkKdIV7kmIevddfwGA5Qk9kgy5sYY,12112
|
|
112
115
|
tui/spinner.py,sha256=Ro6Gd9Przf-whuHqPRY6HwI0T57yJjyNPbhDbigZKZE,2471
|
|
113
116
|
tui/state_handlers.py,sha256=zbUS_D9eU8qIwVpaxPEp9zL9bpg8gXsWNoUaqg9TLrQ,16664
|
|
114
117
|
tui/styles.css,sha256=kiC7Og_2G1E7owoiZgV95-3_dSeQnsNj3qzaY04xkDg,6727
|
|
115
|
-
tui/widget_helpers.py,sha256=
|
|
116
|
-
codeplain-0.3.11.
|
|
117
|
-
codeplain-0.3.11.
|
|
118
|
-
codeplain-0.3.11.
|
|
119
|
-
codeplain-0.3.11.
|
|
120
|
-
codeplain-0.3.11.
|
|
118
|
+
tui/widget_helpers.py,sha256=jitm2WHiKj-NVFL-hULxWzckPreRbUTl9OIZLN31-ek,6997
|
|
119
|
+
codeplain-0.3.11.dev13.dist-info/METADATA,sha256=KVfLUeUZa4B9EB2D8iLyUz7RqGDLrDGSNrGCDwp1MIE,7257
|
|
120
|
+
codeplain-0.3.11.dev13.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
121
|
+
codeplain-0.3.11.dev13.dist-info/entry_points.txt,sha256=oDZkBqu9WhtZApb_K6ia8-fn9aojwmAsgnKELceX5T4,46
|
|
122
|
+
codeplain-0.3.11.dev13.dist-info/licenses/LICENSE,sha256=pCeKgQ1mXE5OmNUuKOfOZh1T1vqkeCUxghE7N8qgnzc,11345
|
|
123
|
+
codeplain-0.3.11.dev13.dist-info/RECORD,,
|
git_preflight.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""Verify a working git is available before GitPython is imported.
|
|
2
|
+
|
|
3
|
+
GitPython probes for the git executable on import and raises from module scope
|
|
4
|
+
if it is missing or broken, so the CLI would crash with a traceback before
|
|
5
|
+
main() could explain it.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import shutil
|
|
9
|
+
import subprocess
|
|
10
|
+
import sys
|
|
11
|
+
|
|
12
|
+
from plain2code_console import console
|
|
13
|
+
|
|
14
|
+
GIT_MISSING_MESSAGE = "git is not installed. Please install git and try again."
|
|
15
|
+
GIT_BROKEN_MESSAGE = "git is installed but not working. Please repair your git installation and try again."
|
|
16
|
+
MACOS_BROKEN_GIT_HINT = (
|
|
17
|
+
"This usually means the Command Line Tools are missing; install them with 'xcode-select --install'."
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def git_runs(git_path):
|
|
22
|
+
"""Whether `git version` succeeds. A git on PATH can still be unusable: on
|
|
23
|
+
macOS without the Command Line Tools /usr/bin/git is a stub that exits with
|
|
24
|
+
an xcrun error, and GIT_PYTHON_REFRESH=quiet does not suppress that."""
|
|
25
|
+
try:
|
|
26
|
+
return subprocess.run([git_path, "version"], capture_output=True, timeout=10).returncode == 0
|
|
27
|
+
except (OSError, subprocess.SubprocessError):
|
|
28
|
+
return False
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def require_git():
|
|
32
|
+
"""Exit with a clean message unless a working git is available."""
|
|
33
|
+
git_path = shutil.which("git")
|
|
34
|
+
if git_path is None:
|
|
35
|
+
console.error(f"{GIT_MISSING_MESSAGE}\n")
|
|
36
|
+
sys.exit(1)
|
|
37
|
+
|
|
38
|
+
if not git_runs(git_path):
|
|
39
|
+
hint = f"\n{MACOS_BROKEN_GIT_HINT}" if sys.platform == "darwin" else ""
|
|
40
|
+
console.error(f"{GIT_BROKEN_MESSAGE}{hint}\n")
|
|
41
|
+
sys.exit(1)
|
plain_modules.py
CHANGED
|
@@ -6,18 +6,18 @@ import tempfile
|
|
|
6
6
|
import zipfile
|
|
7
7
|
from functools import cached_property
|
|
8
8
|
|
|
9
|
+
from git_preflight import require_git
|
|
9
10
|
from plain2code_exceptions import (
|
|
10
|
-
GitNotInstalledError,
|
|
11
11
|
InvalidModuleArchiveError,
|
|
12
12
|
MissingPreviousFunctionalitiesError,
|
|
13
13
|
ModuleDoesNotExistError,
|
|
14
14
|
)
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
# Must run before GitPython is imported, which raises on a missing or broken git.
|
|
17
|
+
require_git()
|
|
18
|
+
|
|
19
|
+
from git import Repo
|
|
20
|
+
from git.exc import NoSuchPathError
|
|
21
21
|
|
|
22
22
|
import file_utils
|
|
23
23
|
import git_utils
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""Regression tests for issue #133.
|
|
2
|
+
|
|
3
|
+
When git is unusable the CLI must report a clean message and exit 1, never dump
|
|
4
|
+
a traceback. The failure is at import time (GitPython raises from module scope
|
|
5
|
+
before main() runs), so the CLI is run in a subprocess and asserted on what a
|
|
6
|
+
user would actually see. sys.executable is launched by absolute path, so
|
|
7
|
+
replacing PATH only controls which git, if any, can be found.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import os
|
|
11
|
+
import re
|
|
12
|
+
import subprocess
|
|
13
|
+
import sys
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
|
|
16
|
+
import pytest
|
|
17
|
+
|
|
18
|
+
from git_preflight import GIT_BROKEN_MESSAGE, GIT_MISSING_MESSAGE
|
|
19
|
+
|
|
20
|
+
REPO_ROOT = Path(__file__).resolve().parents[1]
|
|
21
|
+
TRACEBACK_MARKER = "Traceback (most recent call last)"
|
|
22
|
+
|
|
23
|
+
# The crash was in the import chain, so it hit every entry point equally.
|
|
24
|
+
CLI_INVOCATIONS = [["--version"], ["--status"], ["does-not-exist.plain"]]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def run_cli(args, path_dir=None):
|
|
28
|
+
"""Run the CLI and return its exit code and output, stripped of styling and
|
|
29
|
+
with whitespace collapsed, so assertions survive console line wrapping."""
|
|
30
|
+
env = os.environ.copy()
|
|
31
|
+
# Drop GitPython overrides so the PATH search decides whether git is found.
|
|
32
|
+
env.pop("GIT_PYTHON_GIT_EXECUTABLE", None)
|
|
33
|
+
env.pop("GIT_PYTHON_REFRESH", None)
|
|
34
|
+
env.setdefault("CODEPLAIN_API_KEY", "dummy")
|
|
35
|
+
if path_dir is not None:
|
|
36
|
+
env["PATH"] = str(path_dir)
|
|
37
|
+
|
|
38
|
+
result = subprocess.run(
|
|
39
|
+
[sys.executable, "plain2code.py", *args],
|
|
40
|
+
cwd=REPO_ROOT,
|
|
41
|
+
env=env,
|
|
42
|
+
capture_output=True,
|
|
43
|
+
text=True,
|
|
44
|
+
timeout=120,
|
|
45
|
+
)
|
|
46
|
+
output = re.sub(r"\x1b\[[0-9;]*m", "", result.stdout + result.stderr)
|
|
47
|
+
return result.returncode, " ".join(output.split())
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@pytest.fixture
|
|
51
|
+
def no_git_dir(tmp_path):
|
|
52
|
+
"""A directory containing no git at all, used as the whole PATH."""
|
|
53
|
+
d = tmp_path / "no-git"
|
|
54
|
+
d.mkdir()
|
|
55
|
+
return d
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@pytest.fixture
|
|
59
|
+
def broken_git_dir(tmp_path):
|
|
60
|
+
"""A directory whose git resolves but always fails, used as the whole PATH.
|
|
61
|
+
This is the shape of macOS without the Command Line Tools."""
|
|
62
|
+
d = tmp_path / "broken-git"
|
|
63
|
+
d.mkdir()
|
|
64
|
+
if sys.platform == "win32":
|
|
65
|
+
(d / "git.bat").write_text("@echo off\nexit /b 127\n")
|
|
66
|
+
else:
|
|
67
|
+
git = d / "git"
|
|
68
|
+
git.write_text("#!/bin/sh\nexit 127\n")
|
|
69
|
+
git.chmod(0o755)
|
|
70
|
+
return d
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@pytest.mark.parametrize("args", CLI_INVOCATIONS)
|
|
74
|
+
def test_missing_git_reports_cleanly(args, no_git_dir):
|
|
75
|
+
rc, output = run_cli(args, no_git_dir)
|
|
76
|
+
|
|
77
|
+
assert GIT_MISSING_MESSAGE in output, output
|
|
78
|
+
assert TRACEBACK_MARKER not in output, output
|
|
79
|
+
# GitPython's own advice about GIT_PYTHON_REFRESH must not reach the user.
|
|
80
|
+
assert "GIT_PYTHON_REFRESH" not in output, output
|
|
81
|
+
assert rc == 1, output
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@pytest.mark.parametrize("args", CLI_INVOCATIONS)
|
|
85
|
+
def test_broken_git_reports_cleanly(args, broken_git_dir):
|
|
86
|
+
rc, output = run_cli(args, broken_git_dir)
|
|
87
|
+
|
|
88
|
+
assert GIT_BROKEN_MESSAGE in output, output
|
|
89
|
+
assert GIT_MISSING_MESSAGE not in output, output
|
|
90
|
+
assert TRACEBACK_MARKER not in output, output
|
|
91
|
+
assert rc == 1, output
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_cli_works_when_git_is_present():
|
|
95
|
+
rc, output = run_cli(["--version"])
|
|
96
|
+
|
|
97
|
+
assert rc == 0, output
|
|
98
|
+
assert "codeplain version" in output, output
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""Regression tests: spec-derived text with square brackets must never be parsed as Textual markup."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
|
|
5
|
+
from textual.widgets import Static
|
|
6
|
+
|
|
7
|
+
from event_bus import EventBus
|
|
8
|
+
from plain2code_state import RunState
|
|
9
|
+
from tui.components import ProgressItem, SubstateLine, TUIComponents
|
|
10
|
+
from tui.models import Substate
|
|
11
|
+
from tui.plain2code_tui import Plain2CodeTUI
|
|
12
|
+
from tui.widget_helpers import display_error_message, display_success_message, update_progress_item_substates
|
|
13
|
+
|
|
14
|
+
# Exact acceptance-test text that crashed the TUI with
|
|
15
|
+
# "MarkupError: closing tag '[/#888888]' does not match any open tag":
|
|
16
|
+
# the unterminated "[b" swallowed the timer's opening tag.
|
|
17
|
+
UNTERMINATED_BRACKET_TEXT = (
|
|
18
|
+
"Rendering acceptance test: With a=1, b=2, c=3, d=4: ZRANK z c should reply 2, "
|
|
19
|
+
'ZREVRANK z c WITHSCORE should reply [1, "3"], ZRANK z zz should reply null, '
|
|
20
|
+
"ZCOUNT z (1 3 should reply 2, and ZLEXCOUNT z [b + should reply 3."
|
|
21
|
+
)
|
|
22
|
+
# Terminated brackets used to be silently eaten as a markup tag ("LPOP key ").
|
|
23
|
+
TERMINATED_BRACKET_TEXT = "LPOP key [count] and RPOP key [count] reply one element"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _make_app(run_state: RunState, event_bus: EventBus) -> Plain2CodeTUI:
|
|
27
|
+
return Plain2CodeTUI(
|
|
28
|
+
event_bus=event_bus,
|
|
29
|
+
run_state=run_state,
|
|
30
|
+
on_ready=lambda: None,
|
|
31
|
+
render_id="test-render-id",
|
|
32
|
+
unittests_script=None,
|
|
33
|
+
conformance_tests_script="run_conformance_tests.sh",
|
|
34
|
+
prepare_environment_script=None,
|
|
35
|
+
state_machine_version="0.0.0",
|
|
36
|
+
css_path="styles.css",
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def test_substate_line_keeps_bracket_text_verbatim():
|
|
41
|
+
for text in (UNTERMINATED_BRACKET_TEXT, TERMINATED_BRACKET_TEXT):
|
|
42
|
+
line = SubstateLine(text, " ", ProgressItem.PROCESSING)._format_line()
|
|
43
|
+
assert text in line.plain
|
|
44
|
+
assert line.plain.endswith("(0s)")
|
|
45
|
+
# Only the timer carries the muted style; the text itself is unstyled.
|
|
46
|
+
assert len(line.spans) == 1
|
|
47
|
+
assert line.plain[line.spans[0].start : line.spans[0].end] == "(0s)"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_substate_with_brackets_renders_without_markup_error():
|
|
51
|
+
async def scenario():
|
|
52
|
+
event_bus = EventBus()
|
|
53
|
+
run_state = RunState(spec_filename="x.plain")
|
|
54
|
+
app = _make_app(run_state, event_bus)
|
|
55
|
+
async with app.run_test() as pilot:
|
|
56
|
+
widget_id = TUIComponents.FRID_PROGRESS_CONFORMANCE_TEST.value
|
|
57
|
+
update_progress_item_substates(
|
|
58
|
+
app, widget_id, [Substate(UNTERMINATED_BRACKET_TEXT), Substate(TERMINATED_BRACKET_TEXT)]
|
|
59
|
+
)
|
|
60
|
+
await pilot.pause()
|
|
61
|
+
await pilot.pause()
|
|
62
|
+
|
|
63
|
+
lines = app.query(".substate-line-text").results(Static)
|
|
64
|
+
rendered = [str(line.content) for line in lines]
|
|
65
|
+
assert any(UNTERMINATED_BRACKET_TEXT in text for text in rendered)
|
|
66
|
+
assert any(TERMINATED_BRACKET_TEXT in text for text in rendered)
|
|
67
|
+
|
|
68
|
+
asyncio.run(scenario())
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def test_status_messages_keep_brackets():
|
|
72
|
+
async def scenario():
|
|
73
|
+
event_bus = EventBus()
|
|
74
|
+
run_state = RunState(spec_filename="x.plain")
|
|
75
|
+
app = _make_app(run_state, event_bus)
|
|
76
|
+
async with app.run_test() as pilot:
|
|
77
|
+
status = app.query_one(f"#{TUIComponents.RENDER_STATUS_WIDGET.value}", Static)
|
|
78
|
+
|
|
79
|
+
display_success_message(app, "out/[weird] path")
|
|
80
|
+
await pilot.pause()
|
|
81
|
+
assert "rendering completed!" in str(status.content)
|
|
82
|
+
assert "generated code folder: out/[weird] path" in str(status.content)
|
|
83
|
+
|
|
84
|
+
display_error_message(app, "Error: [Errno 2] No such file: run_tests.sh [b")
|
|
85
|
+
await pilot.pause()
|
|
86
|
+
assert "[Errno 2] No such file: run_tests.sh [b" in str(status.content)
|
|
87
|
+
|
|
88
|
+
asyncio.run(scenario())
|
tui/components.py
CHANGED
|
@@ -3,6 +3,7 @@ from typing import Literal, Optional
|
|
|
3
3
|
|
|
4
4
|
from rich.markup import escape
|
|
5
5
|
from textual.containers import Horizontal, Vertical, VerticalScroll
|
|
6
|
+
from textual.content import Content
|
|
6
7
|
from textual.message import Message
|
|
7
8
|
from textual.timer import Timer
|
|
8
9
|
from textual.widgets import Button, Static
|
|
@@ -71,7 +72,7 @@ class CustomFooter(Horizontal):
|
|
|
71
72
|
self._footer_text_widget = Static(footer_rendering_text, classes="custom-footer-text")
|
|
72
73
|
yield self._footer_text_widget
|
|
73
74
|
if self.render_id:
|
|
74
|
-
yield Static(f"render id: {self.render_id} ", classes="custom-footer-render-id")
|
|
75
|
+
yield Static(f"render id: {self.render_id} ", classes="custom-footer-render-id", markup=False)
|
|
75
76
|
|
|
76
77
|
def update_footer_state(self, state: Literal["rendering", "pausing", "paused", "finished"]) -> None:
|
|
77
78
|
self.remove_class("footer-state-default")
|
|
@@ -201,9 +202,12 @@ class SubstateLine(Horizontal):
|
|
|
201
202
|
def _format_timer(self) -> str:
|
|
202
203
|
return format_duration_hms(self._seconds_elapsed)
|
|
203
204
|
|
|
204
|
-
def _format_line(self) ->
|
|
205
|
+
def _format_line(self) -> Content:
|
|
206
|
+
# The substate text is arbitrary (acceptance-test text from the spec, module names, ...)
|
|
207
|
+
# and may contain square brackets, so it must never go through the markup parser.
|
|
208
|
+
# Build the line as Content and style only the timer part.
|
|
205
209
|
timer = self._format_timer()
|
|
206
|
-
return f"{self.indent} └ {self.text}
|
|
210
|
+
return Content.assemble(f"{self.indent} └ {self.text} ", (f"({timer})", "#888888"))
|
|
207
211
|
|
|
208
212
|
def _refresh_timer(self) -> None:
|
|
209
213
|
try:
|
|
@@ -232,7 +236,7 @@ class ProgressItem(Vertical):
|
|
|
232
236
|
# Main row with status and description
|
|
233
237
|
with Horizontal(id=f"{self.id}-main-row", classes="progress-main-row"):
|
|
234
238
|
yield Static(self._get_status_text(self.PENDING), classes=f"status {self.PENDING}")
|
|
235
|
-
yield Static(self.initial_text, classes="description")
|
|
239
|
+
yield Static(self.initial_text, classes="description", markup=False)
|
|
236
240
|
# Substates container (full width, aligned to left)
|
|
237
241
|
yield Vertical(id=f"{self.id}-substates", classes="substates-container")
|
|
238
242
|
|
|
@@ -367,8 +371,8 @@ class RenderingInfoBox(Vertical):
|
|
|
367
371
|
self._refresh_content()
|
|
368
372
|
|
|
369
373
|
def compose(self):
|
|
370
|
-
self.module_widget = Static(self.module_text, classes="rendering-info-row")
|
|
371
|
-
self.functionality_widget = Static(self.functionality_text, classes="rendering-info-row")
|
|
374
|
+
self.module_widget = Static(self.module_text, classes="rendering-info-row", markup=False)
|
|
375
|
+
self.functionality_widget = Static(self.functionality_text, classes="rendering-info-row", markup=False)
|
|
372
376
|
yield Static("module status", classes="rendering-info-title")
|
|
373
377
|
with Vertical(classes="rendering-info-box"):
|
|
374
378
|
yield self.module_widget
|
|
@@ -430,9 +434,9 @@ class TestScriptsContainer(Vertical):
|
|
|
430
434
|
def compose(self):
|
|
431
435
|
yield Static("testing status", classes="test-scripts-title")
|
|
432
436
|
with Vertical(classes="test-scripts-box"):
|
|
433
|
-
self.unit_widget = Static(self.unit_test_text, classes="test-script-row")
|
|
434
|
-
self.conformance_widget = Static(self.conformance_test_text, classes="test-script-row")
|
|
435
|
-
self.testing_widget = Static(self.testing_env_text, classes="test-script-row")
|
|
437
|
+
self.unit_widget = Static(self.unit_test_text, classes="test-script-row", markup=False)
|
|
438
|
+
self.conformance_widget = Static(self.conformance_test_text, classes="test-script-row", markup=False)
|
|
439
|
+
self.testing_widget = Static(self.testing_env_text, classes="test-script-row", markup=False)
|
|
436
440
|
yield self.unit_widget
|
|
437
441
|
yield self.conformance_widget
|
|
438
442
|
yield self.testing_widget
|
tui/widget_helpers.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from datetime import datetime
|
|
4
4
|
|
|
5
|
+
from textual.content import Content
|
|
5
6
|
from textual.css.query import NoMatches
|
|
6
7
|
from textual.widgets import Static
|
|
7
8
|
|
|
@@ -89,9 +90,14 @@ def display_success_message(tui, rendered_code_path: str):
|
|
|
89
90
|
rendered_code_path: The path to the rendered code
|
|
90
91
|
"""
|
|
91
92
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
# rendered_code_path is user-controlled and may contain square brackets, so build the
|
|
94
|
+
# message as Content instead of interpolating it into a markup string.
|
|
95
|
+
message = Content.assemble(
|
|
96
|
+
("✓ rendering completed!", "#79FC96"),
|
|
97
|
+
" ",
|
|
98
|
+
("(press enter to exit)", "#888888"),
|
|
99
|
+
"\n",
|
|
100
|
+
(f"generated code folder: {rendered_code_path} ", "#888888"),
|
|
95
101
|
)
|
|
96
102
|
|
|
97
103
|
widget: Static = tui.query_one(f"#{TUIComponents.RENDER_STATUS_WIDGET.value}", Static)
|
|
@@ -120,7 +126,8 @@ def transition_frid_progress(tui, from_status: str | None, to_status: str):
|
|
|
120
126
|
def display_error_message(tui, error_message: str):
|
|
121
127
|
widget: Static = tui.query_one(f"#{TUIComponents.RENDER_STATUS_WIDGET.value}", Static)
|
|
122
128
|
widget.add_class("error")
|
|
123
|
-
|
|
129
|
+
# Error text may contain square brackets (paths, tracebacks); keep it out of the markup parser.
|
|
130
|
+
widget.update(Content(error_message))
|
|
124
131
|
|
|
125
132
|
|
|
126
133
|
def display_usage_summary(tui, functionalities: int, render_time_seconds: float) -> None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|