ci,marge_queue: use rich module
As proposed in !37454, we can benefit from `rich` python module to simplify output formatting. Using it here it's only the link print in console what needs to be adjusted. There is a side effect, that look ok, with some coloring in the timestamps and MR ids listed. Signed-off-by: Sergi Blanch Torne <sergi.blanch.torne@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37395>
This commit is contained in:
committed by
Marge Bot
parent
1d38792d62
commit
50c4ec0620
@@ -23,6 +23,7 @@ from gitlab.base import RESTObjectList
|
||||
from gitlab.exceptions import GitlabAuthenticationError
|
||||
from gitlab.v4.objects import Project, ProjectMergeRequest
|
||||
from gitlab_common import read_token, pretty_duration
|
||||
from rich.console import Console
|
||||
|
||||
REFRESH_WAIT = 30
|
||||
MARGE_BOT_USER_ID = 9716
|
||||
@@ -30,9 +31,9 @@ ASSIGNED_TO_MARGE = "assigned to @marge-bot"
|
||||
ASSIGNED_AT_PADDING = 19
|
||||
WAITING_PADDING = 8
|
||||
MR_ID_PADDING = 5
|
||||
URL_START = "\u001b]8;;"
|
||||
URL_SEPARATOR = "\u001b\\"
|
||||
URL_END = "\u001b]8;;\u001b\\"
|
||||
|
||||
console = Console(highlight=False)
|
||||
print = console.print
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
@@ -183,7 +184,7 @@ def __get_project_marge_merge_requests(
|
||||
def link2print(url: str, text: str, text_pad: int = 0) -> str:
|
||||
text = str(text)
|
||||
text_pad = len(text) if text_pad < 1 else text_pad
|
||||
return f"{URL_START}{url}{URL_SEPARATOR}{text:{text_pad}}{URL_END}"
|
||||
return f"[link={url}]{text:{text_pad}}[/link]"
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user