diff --git a/richtest/main.py b/richtest/main.py new file mode 100644 index 0000000..70699e2 --- /dev/null +++ b/richtest/main.py @@ -0,0 +1,84 @@ +from time import sleep + +from rich.console import Console +from rich.progress import Progress +from rich.progress import BarColumn +from rich.progress import TextColumn +from rich.table import Column +from rich.table import Table + +def table_test(): + table = Table() + table.add_column('Count', justify='center') + table.add_column('Case') + table.add_column('Commands', justify='center') + table.add_column('Comparison', justify='center') + + table.add_row('1', 'trainTunnelPar_0 (v18)', '2/3', '0/2') + table.add_row('2', 'cylinderAdjustFlowUFixPar_0 (v12)', '7/7', '1/2') + table.add_row('3', 'propellerPar_0 (v14)', '0/7', '0/2') + table.add_row('4', 'cylinderAdjustFlowUFixPar_0 (v12)', '5/5', '2/2') + + console = Console() + console.print(table) + + +def progress_test1(): + text_column = TextColumn("{task.description}", table_column=Column(ratio=1)) + bar_column = BarColumn(bar_width=None, table_column=Column(ratio=2)) + progress = Progress(text_column, bar_column, expand=True) + + with progress: + for n in progress.track(range(100)): + progress.print(n) + sleep(0.1) + + +def progress_test2(): + with Progress() as progress: + task1 = progress.add_task("[red]Downloading...", total=1000) + task2 = progress.add_task("[green]Processing...", total=1000) + task3 = progress.add_task("[cyan]Cooking...", total=1000) + + while not progress.finished: + progress.update(task1, advance=0.5) + progress.update(task2, advance=0.3) + progress.update(task3, advance=0.9) + sleep(0.02) + + +def color_test(): + console = Console(highlight=False) + console.print(' #', end=' ', style='bright_white on black') + console.print(f'{"Case":<40}', end=' ', style='bright_white on black') + console.print(f'{"Commands":^10}', width=10, end=' ', style='bright_white on black') + console.print(f'{"Compares":^10}', width=10, end=' ', style='bright_white on black') + console.print('Status', width=20, justify='left', style='bright_white on black') + + console.print(f'{1:>4}', end=' ') + console.print(f'{"trainTunnelPar_0":<40}', end=' ') + console.print(f'{"0/5":^10}', end=' ') + console.print(f'{"0/3":^10}', end=' ') + console.print(f'{"Waiting":<20}') + + console.print(f'{2:>4}', end=' ') + console.print(f'{"cylinderAdjustFlowUFixPar_0":<40}', end=' ') + console.print(' ', style='black on white', end=''); console.print(' 2/5 ', end=' ') + console.print(f'{"0/3":^10}', end=' ') + console.print(f'{"Running":<20}', style='green') + + console.print(f'{3:>4}', end=' ') + console.print(f'{"propellerPar_0":<40}', end=' ') + console.print(' 2/', style='black on white', end=''); console.print('4 ', end=' ') + console.print(f'{"0/4":^10}', end=' ') + console.print(f'{"Error":<20}', style='red') + + console.print(f'{4:>4}', end=' ') + console.print(f'{"buildingWithWindowsAndSolarPar_0":<40}', end=' ') + console.print(f'{"5/5":^10}', style='black on white', end=' ') + console.print(f'{"4/4":^10}', end=' ') + console.print(f'{"Failed":<20}', style='orange1') + +if __name__ == '__main__': + # progress_test2() + color_test() diff --git a/richtest/poetry.lock b/richtest/poetry.lock new file mode 100644 index 0000000..e645efd --- /dev/null +++ b/richtest/poetry.lock @@ -0,0 +1,91 @@ +# This file is automatically @generated by Poetry and should not be changed by hand. + +[[package]] +name = "markdown-it-py" +version = "2.2.0" +description = "Python port of markdown-it. Markdown parsing, done right!" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "markdown-it-py-2.2.0.tar.gz", hash = "sha256:7c9a5e412688bc771c67432cbfebcdd686c93ce6484913dccf06cb5a0bea35a1"}, + {file = "markdown_it_py-2.2.0-py3-none-any.whl", hash = "sha256:5a35f8d1870171d9acc47b99612dc146129b631baf04970128b568f190d0cc30"}, +] + +[package.dependencies] +mdurl = ">=0.1,<1.0" +typing_extensions = {version = ">=3.7.4", markers = "python_version < \"3.8\""} + +[package.extras] +benchmarking = ["psutil", "pytest", "pytest-benchmark"] +code-style = ["pre-commit (>=3.0,<4.0)"] +compare = ["commonmark (>=0.9,<1.0)", "markdown (>=3.4,<4.0)", "mistletoe (>=1.0,<2.0)", "mistune (>=2.0,<3.0)", "panflute (>=2.3,<3.0)"] +linkify = ["linkify-it-py (>=1,<3)"] +plugins = ["mdit-py-plugins"] +profiling = ["gprof2dot"] +rtd = ["attrs", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx_book_theme"] +testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"] + +[[package]] +name = "mdurl" +version = "0.1.2" +description = "Markdown URL utilities" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"}, + {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"}, +] + +[[package]] +name = "pygments" +version = "2.15.1" +description = "Pygments is a syntax highlighting package written in Python." +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "Pygments-2.15.1-py3-none-any.whl", hash = "sha256:db2db3deb4b4179f399a09054b023b6a586b76499d36965813c71aa8ed7b5fd1"}, + {file = "Pygments-2.15.1.tar.gz", hash = "sha256:8ace4d3c1dd481894b2005f560ead0f9f19ee64fe983366be1a21e171d12775c"}, +] + +[package.extras] +plugins = ["importlib-metadata"] + +[[package]] +name = "rich" +version = "13.3.5" +description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" +category = "main" +optional = false +python-versions = ">=3.7.0" +files = [ + {file = "rich-13.3.5-py3-none-any.whl", hash = "sha256:69cdf53799e63f38b95b9bf9c875f8c90e78dd62b2f00c13a911c7a3b9fa4704"}, + {file = "rich-13.3.5.tar.gz", hash = "sha256:2d11b9b8dd03868f09b4fffadc84a6a8cda574e40dc90821bd845720ebb8e89c"}, +] + +[package.dependencies] +markdown-it-py = ">=2.2.0,<3.0.0" +pygments = ">=2.13.0,<3.0.0" +typing-extensions = {version = ">=4.0.0,<5.0", markers = "python_version < \"3.9\""} + +[package.extras] +jupyter = ["ipywidgets (>=7.5.1,<9)"] + +[[package]] +name = "typing-extensions" +version = "4.5.0" +description = "Backported and Experimental Type Hints for Python 3.7+" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "typing_extensions-4.5.0-py3-none-any.whl", hash = "sha256:fb33085c39dd998ac16d1431ebc293a8b3eedd00fd4a32de0ff79002c19511b4"}, + {file = "typing_extensions-4.5.0.tar.gz", hash = "sha256:5cb5f4a79139d699607b3ef622a1dedafa84e115ab0024e0d9c044a9479ca7cb"}, +] + +[metadata] +lock-version = "2.0" +python-versions = "^3.7" +content-hash = "8fdb4f607574b1586af3f405991191ac586c60b98ca273c5776cf2a533f98563" diff --git a/richtest/pyproject.toml b/richtest/pyproject.toml new file mode 100644 index 0000000..258a0c3 --- /dev/null +++ b/richtest/pyproject.toml @@ -0,0 +1,15 @@ +[tool.poetry] +name = "richtest" +version = "0.1.0" +description = "" +authors = ["Julio Biason "] +readme = "README.md" + +[tool.poetry.dependencies] +python = "^3.7" +rich = "^13.3.5" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api"