mirror of
https://github.com/rendercv/rendercv.git
synced 2026-04-17 21:39:00 -04:00
* fix render --quiet option issue #608 * format fixed * Improve solution --------- Co-authored-by: Sina Atalay <79940989+sinaatalay@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
18485d7185
commit
cfdaf9cb0f
@@ -1,8 +1,8 @@
|
||||
import contextlib
|
||||
import pathlib
|
||||
from dataclasses import dataclass
|
||||
|
||||
import rich.box
|
||||
import rich.console
|
||||
import rich.live
|
||||
import rich.panel
|
||||
import rich.table
|
||||
@@ -27,7 +27,6 @@ class ProgressPanel(rich.live.Live):
|
||||
"""
|
||||
|
||||
def __init__(self, quiet: bool = False):
|
||||
self.quiet = quiet
|
||||
self.completed_steps: list[CompletedStep] = []
|
||||
super().__init__(
|
||||
rich.panel.Panel(
|
||||
@@ -36,6 +35,7 @@ class ProgressPanel(rich.live.Live):
|
||||
title_align="left",
|
||||
border_style="bright_black",
|
||||
),
|
||||
console=rich.console.Console(quiet=quiet),
|
||||
refresh_per_second=4,
|
||||
)
|
||||
|
||||
@@ -63,18 +63,17 @@ class ProgressPanel(rich.live.Live):
|
||||
Args:
|
||||
title: Panel title text.
|
||||
"""
|
||||
if self.quiet:
|
||||
return
|
||||
|
||||
lines: list[str] = []
|
||||
for step in self.completed_steps:
|
||||
paths_str = ""
|
||||
if step.paths:
|
||||
with contextlib.suppress(ValueError):
|
||||
step.paths = [
|
||||
try:
|
||||
paths = [
|
||||
path.relative_to(pathlib.Path.cwd()) for path in step.paths
|
||||
]
|
||||
paths_as_strings = [f"./{path}" for path in step.paths]
|
||||
except ValueError:
|
||||
paths = step.paths
|
||||
paths_as_strings = [f"./{path}" for path in paths]
|
||||
paths_str = "; ".join(paths_as_strings)
|
||||
|
||||
timing = f"[bold green]{step.timing_ms + ' ms':<8}[/bold green]"
|
||||
|
||||
@@ -51,16 +51,20 @@ class TestProgressPanelFinishProgress:
|
||||
|
||||
|
||||
class TestProgressPanelPrintProgressPanel:
|
||||
def test_quiet_mode_produces_no_output(self, capsys):
|
||||
with ProgressPanel(quiet=True) as panel:
|
||||
panel.update_progress("100", "Test", [])
|
||||
panel.finish_progress()
|
||||
|
||||
captured = capsys.readouterr()
|
||||
assert captured.out == ""
|
||||
|
||||
def test_respects_quiet_mode(self):
|
||||
panel = ProgressPanel(quiet=True)
|
||||
panel.completed_steps.append(CompletedStep("100", "Test", []))
|
||||
|
||||
panel.print_progress_panel("Test Title")
|
||||
|
||||
# In quiet mode, nothing should be printed/updated
|
||||
# We can't easily test the internal state of rich.live.Live, so we just
|
||||
# verify the method doesn't raise an error
|
||||
|
||||
def test_displays_step_without_paths(self):
|
||||
panel = ProgressPanel(quiet=True)
|
||||
panel.completed_steps.append(CompletedStep("100", "Validated input", []))
|
||||
|
||||
Reference in New Issue
Block a user