Refactor photo metadata workflow

This commit is contained in:
ajp_anton
2026-08-24 16:34:20 +00:00
parent 100cad1cb5
commit eb5937a629
15 changed files with 2111 additions and 1727 deletions
+67 -1
View File
@@ -87,7 +87,7 @@ from tools.video_probe import (
)
from tools.video_reporting import _format_probe_timestamp, _format_vfr_timing
from tools.video_reporting import _format_source_span, format_validation_summary_lines
from tools.console import PipelineProgressView, ProgressView, _progress_bar
from tools.console import PipelineProgressView, ProgressView, _progress_bar, stream_is_interactive
from tools.video_encode_output import _update_renderer_progress
from tools.video_timeline import OutputFrameTiming, OutputTimeline, build_output_timeline
from video_encode import (
@@ -681,6 +681,72 @@ class VideoTimelineTests(unittest.TestCase):
"[## 50.0% ###------------]",
)
def test_progress_can_weight_percent_and_eta_by_work(self) -> None:
progress = ProgressView(4, "Applying changes", total_work=10, stream=StringIO())
line = progress.update_line(1, completed_work=5)
self.assertIn("1/4", line)
self.assertIn("50.0%", line)
def test_windows_console_progress_does_not_require_stdout_isatty(self) -> None:
class ConsoleBuffer(StringIO):
def isatty(self) -> bool:
return False
output = ConsoleBuffer()
with (
patch("tools.console.os.name", "nt"),
patch("tools.console.sys.stdout", output),
patch("tools.console._windows_console_output", return_value=True),
):
self.assertTrue(stream_is_interactive(output))
progress = ProgressView(3, "Applying changes", stream=output)
progress.update(1)
progress.update(2)
progress.finish(keep=True)
self.assertEqual(output.getvalue().count("\n"), 1)
def test_single_line_ansi_progress_never_moves_up_zero_lines(self) -> None:
class TtyBuffer(StringIO):
def isatty(self) -> bool:
return True
output = TtyBuffer()
with patch("tools.console.supports_ansi", return_value=True):
progress = ProgressView(3, "Reading metadata", stream=output)
progress.update(1)
progress.update(2)
progress.finish(keep=True)
self.assertNotIn("\x1b[0F", output.getvalue())
def test_progress_redraws_a_wrapped_multi_line_block(self) -> None:
class TtyBuffer(StringIO):
def isatty(self) -> bool:
return True
output = TtyBuffer()
with (
patch("tools.console.supports_ansi", return_value=True),
patch.dict("os.environ", {"COLUMNS": "30"}),
):
progress = ProgressView(3, "Progress", stream=output)
progress.write_lines(
[
"Applying changes",
" Results: succeeded 1 failed 0 metadata 1 no-op 0",
" File ops: rename 0 move 0 rename+move 0",
]
)
progress.write_lines(["Applying changes", " Results: succeeded 2 failed 0 metadata 2 no-op 0"])
progress.finish(keep=True)
rendered = output.getvalue()
self.assertIn("\x1b[2K", rendered)
self.assertIn("\x1b[", rendered)
def test_encoding_progress_matches_persistent_validation_style(self) -> None:
class TtyBuffer(StringIO):
def isatty(self) -> bool: