Skip to content

madbot_cli.render

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.

Attributes

NameDescription
SIGNSThe sign that starts the line of each action.
WORDSThe word that names each action.
WriteWrites a line.

Functions

NameDescription
connection_lineDescribe the plan of a connection.
next_commandsChoose the commands to run after an apply, each with what it is for.
node_stateSay where the data of a node stand after an apply.
pluralWrite a number of things.
reached_stateSay where a submission apply went through stands: failed, sent or waiting.
render_applyWrite the summary of an apply: each node, each submission, then what to run next.
render_associationsWrite the plan of the associations of a node.
render_depositWrite what a deposit holds, and the data it misses.
render_metadataWrite the plan of the metadata of a submission.
render_nodeWrite the plan of a node, then of the nodes under it, each one level further in.
render_planWrite a plan for a person to check.
render_samplesWrite the plan of the samples of a node.
render_sourceWrite the plan of the data of a source on a node.
render_submissionWrite the plan of a submission.
render_summaryWrite the counts of a plan.
render_untrackedWrite what the workspace holds that the file does not mention.
shortShow a value on one line.
submission_stateSay where a submission stands after an apply.

SIGNSattributemodule attribute#

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

The sign that starts the line of each action.

WORDSattributemodule attribute#

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

The word that names each action.

Writeattributemodule attribute#

Write = Callable[[str], None]

Writes a line.

connection_linefunction#

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

Describe the plan of a connection.

Parameters

NameTypeDescription
kindstrsource or repository.
keystrThe key or title it belongs to.
connectionmappingThe plan of the connection.

Returns

str
One line.

next_commandsfunction#

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

NameTypeDescription
reportmappingThe report of apply.
filestrThe deposit file, as given to apply.
submitboolWhether apply was run with --submit.

Returns

list of tuple
Each command, and why to run it; empty when nothing is left to do.

node_statefunction#

def node_state(node: Mapping) -> str

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

Parameters

NameTypeDescription
nodemappingA node of the report of apply.

Returns

str
Such as 12 data read, 2 failed to read.

pluralfunction#

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

Write a number of things.

Parameters

NameTypeDescription
numberintHow many.
nounstrThe thing, in the singular.

Returns

str
Such as 1 value or 2 values.

reached_statefunction#

def reached_state(submission: Mapping) -> str

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

Parameters

NameTypeDescription
submissionmappingA submission of the report of apply, neither left nor refused.

Returns

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

render_applyfunction#

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

NameTypeDescription
writecallableWrites a line.
reportmappingThe report of apply.
filestrThe deposit file, as given to apply.
submitboolWhether apply was run with --submit.

render_associationsfunction#

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

Write the plan of the associations of a node.

Parameters

NameTypeDescription
writecallableWrites a line.
associationsmappingTheir plan.
verboseboolList the associations left as they are too.

render_depositfunction#

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

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

Parameters

NameTypeDescription
writecallableWrites a line.
submissionmappingThe plan of a deposited submission.

render_metadatafunction#

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

Write the plan of the metadata of a submission.

Parameters

NameTypeDescription
writecallableWrites a line.
metadatamapping or str or NoneTheir plan, or after apply when the submission does not exist yet.

render_nodefunction#

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

NameTypeDefaultDescription
writecallablerequiredWrites a line.
nodemappingrequiredThe plan of the node.
verboseboolrequiredList the objects left as they are too.
depthint0How deep the node is, 0 at the top of the workspace.

render_planfunction#

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

Write a plan for a person to check.

Parameters

NameTypeDefaultDescription
writecallablerequiredWrites a line.
resultmappingrequiredThe plan made by madbot_cli.plan.plan.
verboseboolFalseList the objects left as they are too.

render_samplesfunction#

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

Write the plan of the samples of a node.

Parameters

NameTypeDescription
writecallableWrites a line.
samplesmappingTheir plan.
verboseboolList the samples left as they are too.

render_sourcefunction#

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

NameTypeDescription
writecallableWrites a line.
keystrThe key of the source.
sourcemappingThe plan of its data on the node.
verboseboolList the data left as they are too.

render_submissionfunction#

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

Write the plan of a submission.

Parameters

NameTypeDescription
writecallableWrites a line.
submissionmappingIts plan.

render_summaryfunction#

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

Write the counts of a plan.

Parameters

NameTypeDescription
writecallableWrites a line.
summarymappingThe summary of a plan.

render_untrackedfunction#

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

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

Parameters

NameTypeDescription
writecallableWrites a line.
resultmappingA plan.

shortfunction#

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

Show a value on one line.

Parameters

NameTypeDefaultDescription
valueAnyrequiredThe value.
widthint60The longest text kept.

Returns

str
The value as JSON-like text, cut at width.

submission_statefunction#

def submission_state(submission: Mapping) -> str

Say where a submission stands after an apply.

Parameters

NameTypeDescription
submissionmappingA submission of the report of apply.

Returns

str
Such as ready or draft, 3 mandatory values missing.