Skip to content

Commit acc4ce0

Browse files
committed
modified: .github/actions/recent-posts/main.py
- Capturing string repr of table using rich.console capturing.
1 parent 89d1d2d commit acc4ce0

File tree

1 file changed

+7
-3
lines changed
  • .github/actions/recent-posts

1 file changed

+7
-3
lines changed

.github/actions/recent-posts/main.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pydantic_xml.model import (
1010
attr, BaseXmlModel, computed_element, element, wrapped
1111
)
12-
from rich import print
12+
from rich.console import Console
1313
from rich.table import Table
1414
from typer import Typer
1515
from typer.params import Argument
@@ -66,8 +66,12 @@ def main(
6666
model.entry.published.strftime("%Y-%m-%d %I:%M%p"),
6767
)
6868
)
69-
new_text = re.sub(pattern=pattern, repl=str(table), string=text)
70-
print(new_text)
69+
console = Console()
70+
with console.capture() as capture:
71+
console.print(table)
72+
73+
repl = capture.get()
74+
new_text = re.sub(pattern=pattern, repl=repl, string=text)
7175
with readme.open(mode="w") as f:
7276
f.write(new_text)
7377

0 commit comments

Comments
 (0)