/usr/lib/python2.7/dist-packages/otherstuf/chainstuf.py is in python-otherstuf 1.1.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | """
Sidecar to `stuf` that adds `ChainMap`-like
container `chainstuf`
"""
try:
from collections import ChainMap
except ImportError:
from stuf.collects import ChainMap
class chainstuf(ChainMap):
"""
A stuf-like surfacing of the ChainMap collection
(multi-layer dict) introduced in Python 3. Uses a
workalike replacement under Python 2.
"""
def __init__(self, *maps):
ChainMap.__init__(self, *maps)
def __getattr__(self, key):
for m in self.maps:
try:
return m[key]
except KeyError:
pass
raise KeyError(key)
def __setattr__(self, key, value):
# handle normal object attributes
if key == 'maps' or key in self.__dict__:
ChainMap.__setattr__(self, key, value)
else:
self.maps[0][key] = value
|