recognition1581%python.module
fault.vector

System argument vector interpretation methods.

legacy is the only implemented method and should cover most use cases.

Events

mismatch-unrecognized

The signalled option did not appear in either index.

mismatch-parameter-restricted

The long option was given a parameter, but the option takes none.

mismatch-parameter-required

The option requires a parameter, but no argument was provided. Either due to end of fields or explicit termination.

sequence-append

Append the option's arguments to the slots.

set-add

Add the option's argument to the set identified by the slot.

field-replace

Assign the option's argument to the field identified by the slot.

integer-add

Add a positive or negative integer to the field identified by the slot.

subfield-replace

Using the mapping identified by the slot, assign the key and value extracted from the argument.

sequence-append-assignment

Using the sequence identified by the slot, append the tuple representing assignment provided as the argument to the option.

UsageViolation0
class

Exception signalling that options were not properly expressed.

UsageViolationProperties

mismatch
'mismatch-unrecognized'

The option could not be mapped to an action and configuration slot.

'mismatch-parameter-required'

The option required a parameter and the argument vector had no more elements.

'mismatch-parameter-restricted'

The option was given an argument, but takes zero.

origin

The location of the option as cited by the mismatch event.

option

The identified option being processed.

argument

The option's identified argument if any.

UsageViolation__init__
method

__init__(self, mismatch, origin, option)

UsageViolation__str__30%
method

__str__(self)

legacy1179%
function

legacy(restricted, required, options, trap, offset, signal, assignment)

Interpret an argument vector, options, according to the restricted and required option indexes. Identified signals are translated into events describing the expected operation, target slot, and value to be processed by a configuration context.

The produced events are terminated by a 'remainder' event containing the excess fields that could not be translated. If all fields were processed as options, the remainder will be an empty list.

In the case of an error, the event prior to the remainder will be identified as a mismatch operation with the slot identifying the option that failed to match an index entry.

legacyParameters

restricted

Mapping designating the options that take no parameters.

required

Mapping designating the options that require one or more parameters.

options

The argument vector to interpret.

trap

Optional slot identifier used when an unrecognized long option is processed. Produces sequence-append events.

offset

Defaults to zero; designates the offset to apply to field indexes in order to properly mention a flag or parameter's location.

signal

Defaults to -; the character used to identify options in the vector.

assignment

Defaults to =; the character used to separate a long option's name from its argument.

_sfr0
function

_sfr(t, k, i, v)

_seq0
function

_seq(t, k, i, v)

operations0
data

operations = {
	'field-replace': (lambda t, k, i, v: t.__setitem__(k, i(k, v))),
	'sequence-append': (lambda t, k, i, v: t[k].append(i(k, v))),
	'set-add': (lambda t, k, i, v: t[k].add(i(k, v))),
	'set-discard': (lambda t, k, i, v: t[k].discard(i(k, v))),
	'integer-add': (lambda t, k, i, v: t.__setitem__(k, t.get(k, 0) + int(i(k, v)))),
	'subfield-replace': _sfr,
	'sequence-append-assignment': _seq,
}

merge191%
function

merge(target, events, Interpreter, Operations)

Apply the values provided by events into target using the event's operation to select the merge method provided in Operations.

mergeParameters

target

The object that the interpreted options and arguments are being inserted into. A configuration dictionary.

events

An iterable producing recognized option events. Normally, constructed by legacy.

Interpreter

A function called with the slot being assigned and value that needs to be interpreted prior to the storage operation.

Defaults to a reflection of the given value(no-op).

Operations

A mapping designating how an assignment operation is to be performed against the target.

Defaults to operations.