anod.qualifier

Qualifier dictionary with custom operators for Anod specs.

Module Contents

Classes

Qualifier

A dictionary of qualifiers.

class anod.qualifier.Qualifier

Bases: dict

A dictionary of qualifiers.

This class is just a dict with some surcharged methods for ease of use.

__sub__(other: collections.abc.Iterable[str]) Qualifier

Create a new dict qualifier with some keys filtered-out.

Parameters:

other – iterable of keys to filter out

Examples: .. code:

{"k1": "v1", "k2": "v2"} - {"k2"} == {"k1": "v1"}
{"k1": "v1", "k2": "v2"} - {"k2": "v3"} == {"k1": "v1"}
__add__(other: dict | None) Qualifier

Create a new dict qualifier that merges two dicts.

The operation is equivalent to pipe operator with the difference that its priority is higher as defined by Python standard. This allows more natural expression that mix + and - operators (both operators have the same priority).

Parameters:

other – dictionary to merge with

__and__(other: collections.abc.Iterable[str]) Qualifier

Create a new dict qualifier with the subset other of the keys.

Parameters:

other – iterable of keys to keep

Examples: .. code:

{"k1": "v1", "k2": "v2"} & {"k2"} == {"k2": "v2"}
{"k1": "v1", "k2": "v2"} & {"k2": "v3"} == {"k2": "v2"}