zabgrab.model.itemspec

Conversion between item specs and their command line form.

Forms accepted by --item:

  • 12345: an item ID

  • host=demo1,name=Particles *: comma-separated field=value pairs, with fields itemid, host, name, key and tag

  • Particles *: anything else without = is a name pattern

Values may contain commas (common in item keys such as net.if.in[eth0,bytes]); only a comma followed by field= starts a new pair.

zabgrab.model.itemspec.FIELDS

The fields an item spec can have.

Type:

tuple of str

zabgrab.model.itemspec.EXAMPLE

Examples of the command line form, for messages.

Type:

str

Functions

format_item_spec(spec)

Write an item spec in its command line form.

parse_item_spec(text)

Parse the command line form of an item spec.

zabgrab.model.itemspec.parse_item_spec(text)[source]

Parse the command line form of an item spec.

Parameters:

text (str) – An --item value (see the module docstring).

Returns:

ItemSpec – The item spec.

Raises:

ValueError – With a message suitable for showing to the user.

Return type:

ItemSpec

zabgrab.model.itemspec.format_item_spec(spec)[source]

Write an item spec in its command line form.

The inverse of parse_item_spec().

Parameters:

spec (ItemSpec) – The item spec.

Returns:

str – The --item value that gives spec.

Raises:

ValueError – If the spec’s host is a choice, which has no command line form.

Return type:

str