# madbot_cli.render

*module*

Write plans and reports for a person to read.

Each line starts with a sign: ``+`` to create, ``~`` to update, ``=``
unchanged, ``!`` to look at. ``--json`` prints the same content for a program.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L1-1)

## madbot_cli.render.SIGNS

*attribute* · *module attribute*

```python
SIGNS = {CREATE: '+', UPDATE: '~', CONNECT: '~', UNCHANGED: '=', DEPOSITED: '='}
```

The sign that starts the line of each action.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L18-18)

## madbot_cli.render.WORDS

*attribute* · *module attribute*

```python
WORDS = {CREATE: 'create', UPDATE: 'update', CONNECT: 'give the credentials', UNCHANGED: 'unchanged', DEPOSITED: 'deposited'}
```

The word that names each action.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L20-26)

## madbot_cli.render.Write

*attribute* · *module attribute*

```python
Write = Callable[[str], None]
```

Writes a line.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L29-29)

## madbot_cli.render.connection_line

*function*

```python
def connection_line(kind: str, key: str, connection: Mapping) -> str
```

Describe the plan of a connection.

**Parameters**

- `kind` (`str`) — ``source`` or ``repository``.
- `key` (`str`) — The key or title it belongs to.
- `connection` (`mapping`) — The plan of the connection.

**Returns**

- (`str`) — One line.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L53-92)

## madbot_cli.render.next_commands

*function*

```python
def next_commands(report: Mapping, file: str, submit: bool) -> list[tuple[str, str]]
```

Choose the commands to run after an apply, each with what it is for.

**Parameters**

- `report` (`mapping`) — The report of apply.
- `file` (`str`) — The deposit file, as given to apply.
- `submit` (`bool`) — Whether apply was run with ``--submit``.

**Returns**

- (`list of tuple`) — Each command, and why to run it; empty when nothing is left to do.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L553-628)

## madbot_cli.render.node_state

*function*

```python
def node_state(node: Mapping) -> str
```

Say where the data of a node stand after an apply.

**Parameters**

- `node` (`mapping`) — A node of the report of apply.

**Returns**

- (`str`) — Such as ``12 data read, 2 failed to read``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L469-495)

## madbot_cli.render.plural

*function*

```python
def plural(number: int, noun: str) -> str
```

Write a number of things.

**Parameters**

- `number` (`int`) — How many.
- `noun` (`str`) — The thing, in the singular.

**Returns**

- (`str`) — Such as ``1 value`` or ``2 values``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L450-466)

## madbot_cli.render.reached_state

*function*

```python
def reached_state(submission: Mapping) -> str
```

Say where a submission apply went through stands: failed, sent or waiting.

**Parameters**

- `submission` (`mapping`) — A submission of the report of apply, neither left nor refused.

**Returns**

- (`str`) — Such as ``ready`` or ``sent (submitted), PRJEB1234``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L519-550)

## madbot_cli.render.render_apply

*function*

```python
def render_apply(write: Write, report: Mapping, file: str, submit: bool) -> None
```

Write the summary of an apply: each node, each submission, then what to run next.

**Parameters**

- `write` (`callable`) — Writes a line.
- `report` (`mapping`) — The report of apply.
- `file` (`str`) — The deposit file, as given to apply.
- `submit` (`bool`) — Whether apply was run with ``--submit``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L631-666)

## madbot_cli.render.render_associations

*function*

```python
def render_associations(write: Write, associations: Mapping, verbose: bool) -> None
```

Write the plan of the associations of a node.

**Parameters**

- `write` (`callable`) — Writes a line.
- `associations` (`mapping`) — Their plan.
- `verbose` (`bool`) — List the associations left as they are too.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L164-200)

## madbot_cli.render.render_deposit

*function*

```python
def render_deposit(write: Write, submission: Mapping) -> None
```

Write what a deposit holds, and the data it misses.

**Parameters**

- `write` (`callable`) — Writes a line.
- `submission` (`mapping`) — The plan of a deposited submission.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L239-261)

## madbot_cli.render.render_metadata

*function*

```python
def render_metadata(write: Write, metadata: Mapping | str | None) -> None
```

Write the plan of the metadata of a submission.

**Parameters**

- `write` (`callable`) — Writes a line.
- `metadata` (`mapping or str or None`) — Their plan, or ``after apply`` when the submission does not exist yet.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L203-236)

## madbot_cli.render.render_node

*function*

```python
def render_node(write: Write, node: Mapping, verbose: bool, depth: int = 0) -> None
```

Write the plan of a node, then of the nodes under it, each one level further in.

**Parameters**

- `write` (`callable`) — Writes a line.
- `node` (`mapping`) — The plan of the node.
- `verbose` (`bool`) — List the objects left as they are too.
- `depth` (`int`) (default: `0`) — How deep the node is, 0 at the top of the workspace.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L319-356)

## madbot_cli.render.render_plan

*function*

```python
def render_plan(write: Write, result: Mapping, verbose: bool = False) -> None
```

Write a plan for a person to check.

**Parameters**

- `write` (`callable`) — Writes a line.
- `result` (`mapping`) — The plan made by `madbot_cli.plan.plan`.
- `verbose` (`bool`) (default: `False`) — List the objects left as they are too.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L422-447)

## madbot_cli.render.render_samples

*function*

```python
def render_samples(write: Write, samples: Mapping, verbose: bool) -> None
```

Write the plan of the samples of a node.

**Parameters**

- `write` (`callable`) — Writes a line.
- `samples` (`mapping`) — Their plan.
- `verbose` (`bool`) — List the samples left as they are too.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L132-161)

## madbot_cli.render.render_source

*function*

```python
def render_source(write: Write, key: str, source: Mapping, verbose: bool) -> None
```

Write the plan of the data of a source on a node.

**Parameters**

- `write` (`callable`) — Writes a line.
- `key` (`str`) — The key of the source.
- `source` (`mapping`) — The plan of its data on the node.
- `verbose` (`bool`) — List the data left as they are too.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L95-129)

## madbot_cli.render.render_submission

*function*

```python
def render_submission(write: Write, submission: Mapping) -> None
```

Write the plan of a submission.

**Parameters**

- `write` (`callable`) — Writes a line.
- `submission` (`mapping`) — Its plan.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L264-316)

## madbot_cli.render.render_summary

*function*

```python
def render_summary(write: Write, summary: Mapping) -> None
```

Write the counts of a plan.

**Parameters**

- `write` (`callable`) — Writes a line.
- `summary` (`mapping`) — The ``summary`` of a plan.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L382-419)

## madbot_cli.render.render_untracked

*function*

```python
def render_untracked(write: Write, result: Mapping) -> None
```

Write what the workspace holds that the file does not mention.

**Parameters**

- `write` (`callable`) — Writes a line.
- `result` (`mapping`) — A plan.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L359-379)

## madbot_cli.render.short

*function*

```python
def short(value: Any, width: int = 60) -> str
```

Show a value on one line.

**Parameters**

- `value` (`Any`) — The value.
- `width` (`int`) (default: `60`) — The longest text kept.

**Returns**

- (`str`) — The value as JSON-like text, cut at `width`.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L33-50)

## madbot_cli.render.submission_state

*function*

```python
def submission_state(submission: Mapping) -> str
```

Say where a submission stands after an apply.

**Parameters**

- `submission` (`mapping`) — A submission of the report of apply.

**Returns**

- (`str`) — Such as ``ready`` or ``draft, 3 mandatory values missing``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/render.py#L498-516)
