zabgrab.services.templates

Turning a fetch into a template (--save-template) or an equivalent command.

Functions

equivalent_command(args, answers)

Build the command that repeats a fetch without its prompts.

template_table(cli, query, config)

Build the template that repeats a fetch, as a config table.

Classes

Equivalent(args[, notes])

The command that repeats a fetch without its prompts.

zabgrab.services.templates.template_table(cli, query, config)[source]

Build the template that repeats a fetch, as a config table.

It’s self-contained, since templates can’t build on each other: the template used contributes its items and settings, overridden by the command line and by answers given at prompts. [defaults] and built-in values are left out, so they still apply when the template is used. Values are kept as given (patterns, relative times).

Parameters:
  • cli (CliRequest) – What was given on the command line.

  • query (Query) – The fetch, including the answers given at prompts.

  • config (Config) – The config, for the template used.

Returns:

dict – The template’s settings, as config values.

Return type:

dict[str, Any]

class zabgrab.services.templates.Equivalent(args, notes=<factory>)[source]

Bases: object

The command that repeats a fetch without its prompts.

Parameters:
args

The command line arguments (after the program name).

Type:

list of str

notes

Answers the command can’t include, as sentences.

Type:

list of str

property command: str

Get the command, quoted for a shell.

zabgrab.services.templates.equivalent_command(args, answers)[source]

Build the command that repeats a fetch without its prompts.

Answers become options, replacing any given for the same setting.

Parameters:
  • args (sequence of str) – The command line as given (after the program name).

  • answers (Answers) – The answers given at prompts.

Returns:

Equivalent – The command, and notes on answers it can’t include (items chosen from a template, several formats).

Return type:

Equivalent