patroni.collections module
Patroni custom object types somewhat like collections module.
Provides a case insensitive dict and set object types, and EMPTY_DICT frozen dictionary object.
- class patroni.collections.CaseInsensitiveDict(data: Dict[str, Any] | None = None)
Bases:
MutableMapping[str,Any]A case-insensitive
dict-like object.Implements all methods and operations of
MutableMappingas well asdict’scopy(). All keys are expected to be strings. The structure remembers the case of the last key to be set, anditer(),dict.keys(),dict.items(),dict.iterkeys(), anddict.iteritems()will contain case-sensitive keys. However, querying and contains testing is case insensitive.- __init__(data: Dict[str, Any] | None = None) None
Create a new instance of
CaseInsensitiveDictwith the given data.- Parameters:
data – initial dictionary to create a
CaseInsensitiveDictfrom.
- _abc_impl = <_abc._abc_data object>
- copy() CaseInsensitiveDict
Create a copy of this dict.
- Returns:
a new dict object with the same keys and values of this dict.
- class patroni.collections.CaseInsensitiveSet(values: Collection[str] | None = None)
Bases:
MutableSet[str]A case-insensitive
set-like object.Implements all methods and operations of
MutableSet. All values are expected to be strings. The structure remembers the case of the last value set, however, contains testing is case insensitive.- __init__(values: Collection[str] | None = None) None
Create a new instance of
CaseInsensitiveSetwith the given values.- Parameters:
values – values to be added to the set.
- _abc_impl = <_abc._abc_data object>
- add(value: str) None
Add value to this set.
Search is performed case-insensitively. If value is already in the set, overwrite it with value, so we “remember” the last case of value.
- Parameters:
value – value to be added to the set.
- discard(value: str) None
Remove value from this set.
Search is performed case-insensitively. If value is not present in the set, no exception is raised.
- Parameters:
value – value to be removed from the set.
- issubset(other: CaseInsensitiveSet) bool
Check if this set is a subset of other.
- Parameters:
other – another set to be compared with this set.
- Returns:
Trueif this set is a subset of other, elseFalse.