onyo.argparse_helpers module

class onyo.argparse_helpers.StoreMultipleKeyValuePairs(option_strings, dest, nargs=None, **kwargs)[source]

Bases: Action

Store a list of dictionaries of key-value pairs.

__call__(parser, namespace, key_values, option_string=None)[source]

Turn a list of ‘KEY=VALUE’ pairs into a list of dictionaries.

Each KEY can be defined either 1 or N times (where N is the number of dictionaries to be created).

A KEY that is declared once will apply to all dictionaries.

All KEYs appearing N times must appear the same number of times. If not, a message will print to standard error and the program will exit with status code 2.

Parameters:
  • parser (ArgumentParser)

  • namespace (Namespace)

  • key_values (list[str]) – List of strings containing key-value pairs.

  • option_string (str | None (default: None))

Return type:

None

__init__(option_strings, dest, nargs=None, **kwargs)[source]
Parameters:
  • option_strings (Sequence[str])

  • dest (str)

  • nargs (int | str | None (default: None))

  • **kwargs

class onyo.argparse_helpers.StoreSingleKeyValuePairs(option_strings, dest, nargs=None, **kwargs)[source]

Bases: Action

Store a dictionary of key-value pairs.

__call__(parser, namespace, key_values, option_string=None)[source]

Turn a list of ‘KEY=VALUE’ pairs into a dictionary.

Each KEY can be defined once. If defined more than once, a message will print to standard error and the program will exit with status code 2.

Parameters:
  • parser (ArgumentParser)

  • namespace (Namespace)

  • key_values (list[str]) – List of strings containing key-value pairs.

  • option_string (str | None (default: None))

Return type:

None

__init__(option_strings, dest, nargs=None, **kwargs)[source]
Parameters:
  • option_strings (Sequence[str])

  • dest (str)

  • nargs (int | str | None (default: None))

  • **kwargs

class onyo.argparse_helpers.StoreSortOption(option_strings, dest, **kwargs)[source]

Bases: Action

__call__(parser, namespace, values, option_string=None)[source]

Call self as a function.

__init__(option_strings, dest, **kwargs)[source]
Parameters:
  • option_strings (Sequence[str])

  • dest (str)

  • **kwargs