Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tk GUI #34

Open
jeffwright13 opened this issue Jun 27, 2022 · 2 comments
Open

Tk GUI #34

jeffwright13 opened this issue Jun 27, 2022 · 2 comments
Assignees

Comments

@jeffwright13
Copy link
Owner

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 jeffwright13 self-assigned this Jun 27, 2022
@jeffwright13
Copy link
Owner Author

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:

  • 39: Default foreground color; 49: Default background color; 00m: Reset
  • 94m: Set bright foreground color (blue)
  • 31m: Set foreground color (red)
  • 32m: Set foreground color (green)
  • 33m: Set foreground color (yellow)
  • 34m: Set foreground color (blue)
  • 35m: Set foreground color (magenta)
  • 36m: Set foreground color (cyan)
  • 37m: Set foreground color (white)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant