Metadata-Version: 2.4
Name: nornir-rich-panelvar
Version: 0.2.0.post1
Summary: Fork of nornir-rich to support placing each individual nornir result var into its own dedicated rich panel (which in turn prettifies dictionary keys/values)
License: Apache-2.0
Author: ubaumann
Author-email: github@m.ubaumann.ch
Requires-Python: >=3.8,<4.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: nornir (>=3,<4)
Requires-Dist: rich (>=12,<14)
Project-URL: Repository, https://github.com/sjhloco/nornir_rich
Description-Content-Type: text/markdown

# nornir_rich_panelvar

This is a fork of [nornir-rich](https://github.com/InfrastructureAsCode-ch/nornir_rich), I have published it separately as am not sure if the original package is still maintained ([issue20](https://github.com/InfrastructureAsCode-ch/nornir_rich/issues/20)) and need a way to enable the installation of my forked changes as a PyPI dependency.

- The [per_panel_var](https://github.com/sjhloco/nornir_rich/tree/per_panel_var) branch (of changes) has been retained incase the package maintainer ever agrees to a PR for the changes in this fork
- Github actions are disabled in this fork as they fail on the first python version (3.8) due to an issue with poetry install

## Extra features added by this fork

The following extra options can be set in the *print_result* method, the defaults keep the original *nornir-rich* behaviour:

- *print_empty_task* (default True): If set to *False* will not print a task if the task *result* is *Null* or an empty string (*""*)
- *per_panel_var* (default False): If set to *True* puts each individual nornir *result var* into its own dedicated *rich panel*. If the var is a dictionary rather than having the var name (for example *result*) within the panel it prettifies it to instead use the key for each dictionary item (all displayed in the one panel)

```python
print_result(
    results,
    vars=["name", "result"],
    print_empty_task=False,
    per_panel_var=True,
)
```

<img width="1491" height="743" alt="Image" src="https://github.com/user-attachments/assets/08cfb946-479f-464e-81a8-45b4efb2a5b2" />

## Install

```bash
pip install nornir-rich
```

> The rest of the README is from the original nornir_rich package

## Usage

Features

- Print functions
  - `print_result`
  - `print_failed_hosts`
  - `print_inventory`
- Processors
  - `progressbar`


### Print example

```python
from nornir_rich.functions import print_result

results = nr.run(
    task=hello_world
)

print_result(results)
print_result(results, vars=["diff", "result", "name", "exception", "severity_level"])
```

### Progress bar example

```python
from time import sleep
from nornir_rich.progress_bar import RichProgressBar


def random_sleep(task: Task) -> Result:
    delay = randrange(10)
    sleep(delay)
    return Result(host=task.host, result=f"{delay} seconds delay")


nr_with_processors = nr.with_processors([RichProgressBar()])
result = nr_with_processors.run(task=random_sleep)
```


## Images

### Print Inventory

![Print inventory](docs/imgs/print_inventory.png)

### Print Result

![Print Result](docs/imgs/print_result.png)

### Progress Bar

![Progress Bar](docs/imgs/progressbar.png)


More [examples](docs/imgs/print_functions.ipynb)

