mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-08-19 12:59:42 -07:00
Update jaraco.collections==3.5.1
[skip ci]
This commit is contained in:
parent
addf9ea324
commit
3e8ef3c1b4
1 changed files with 17 additions and 4 deletions
|
@ -573,12 +573,16 @@ class DictStack(list, collections.abc.Mapping):
|
||||||
2
|
2
|
||||||
>>> stack['c']
|
>>> stack['c']
|
||||||
2
|
2
|
||||||
|
>>> len(stack)
|
||||||
|
3
|
||||||
>>> stack.push(dict(a=3))
|
>>> stack.push(dict(a=3))
|
||||||
>>> stack['a']
|
>>> stack['a']
|
||||||
3
|
3
|
||||||
>>> set(stack.keys()) == set(['a', 'b', 'c'])
|
>>> set(stack.keys()) == set(['a', 'b', 'c'])
|
||||||
True
|
True
|
||||||
>>> dict(**stack) == dict(a=3, c=2, b=2)
|
>>> set(stack.items()) == set([('a', 3), ('b', 2), ('c', 2)])
|
||||||
|
True
|
||||||
|
>>> dict(**stack) == dict(stack) == dict(a=3, c=2, b=2)
|
||||||
True
|
True
|
||||||
>>> d = stack.pop()
|
>>> d = stack.pop()
|
||||||
>>> stack['a']
|
>>> stack['a']
|
||||||
|
@ -587,19 +591,28 @@ class DictStack(list, collections.abc.Mapping):
|
||||||
>>> stack['a']
|
>>> stack['a']
|
||||||
1
|
1
|
||||||
>>> stack.get('b', None)
|
>>> stack.get('b', None)
|
||||||
|
>>> 'c' in stack
|
||||||
|
True
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def keys(self):
|
def __iter__(self):
|
||||||
return list(set(itertools.chain.from_iterable(c.keys() for c in self)))
|
dicts = list.__iter__(self)
|
||||||
|
return iter(set(itertools.chain.from_iterable(c.keys() for c in dicts)))
|
||||||
|
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
for scope in reversed(self):
|
for scope in reversed(tuple(list.__iter__(self))):
|
||||||
if key in scope:
|
if key in scope:
|
||||||
return scope[key]
|
return scope[key]
|
||||||
raise KeyError(key)
|
raise KeyError(key)
|
||||||
|
|
||||||
push = list.append
|
push = list.append
|
||||||
|
|
||||||
|
def __contains__(self, other):
|
||||||
|
return collections.abc.Mapping.__contains__(self, other)
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(list(iter(self)))
|
||||||
|
|
||||||
|
|
||||||
class BijectiveMap(dict):
|
class BijectiveMap(dict):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue