jeffwright13 / pytest-tui

A Text User Interface (TUI) for Pytest, with console scripts to launch a TUI or an HTML page
MIT License
34 stars 1 forks source link

Tk GUI #34

Open jeffwright13 opened 2 years ago

jeffwright13 commented 2 years ago

https://stackoverflow.com/questions/65335142/how-can-i-use-text-with-html-tags-in-a-tkinter-text-box-or-change-it-so-that-it

https://stackoverflow.com/questions/37084313/how-to-display-rendered-html-content-in-text-widget-of-tkinter-in-python-3-4-x

Will need to write some code to convert ANSI color and bold sequences to HTML

jeffwright13 commented 2 years ago

https://en.wikipedia.org/wiki/ANSI_escape_code https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797 https://notes.burke.libbey.me/ansi-escape-codes/

jeffwright13 commented 2 years ago

The following code decodes the unmarked_output.bin output file from pytest-tui, and provides a list of unique ANSI SVG codes:

import fire
import re
from pathlib import Path

def decode_ansi(lines: list):
    matcher = r"(\x9B|\x1B\[)([0-?]*[ -\/]*[@-~])"
    matches = []
    for line in lines:
        match = re.findall(matcher, line)
        if match:
            matches.append(match)
    return matches

def main(ansi_file: Path):
    with open (Path(ansi_file)) as f:
        lines = f.readlines()
    unique_codes = []
    code_lines = decode_ansi(lines)
    for line in code_lines:
        unique_codes.extend([code[1] for code in line if code[1]])
    print(set(unique_codes))

if __name__ == "__main__":
    fire.Fire(main)

The outcome of this is that there are only a handful of unique codes being used by Pytest:

{'39;49;00m', '94m', '33m', '1m', '31m', '37m', '35m', '0m', '92m', '96m', '32m'}

These correspond to: