/usr/lib/python3/dist-packages/zict/common.py is in python3-zict 0.1.3-1.
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | from __future__ import absolute_import, division, print_function
from collections import Mapping, MutableMapping
class ZictBase(MutableMapping):
"""
Base class for zict mappings.
"""
def update(*args, **kwds):
# Boilerplate for implementing an update() method
if not args:
raise TypeError("descriptor 'update' of MutableMapping object "
"needs an argument")
self = args[0]
args = args[1:]
if len(args) > 1:
raise TypeError('update expected at most 1 arguments, got %d' %
len(args))
items = []
if args:
other = args[0]
if isinstance(other, Mapping) or hasattr(other, "items"):
items += other.items()
else:
# Assuming (key, value) pairs
items += other
if kwds:
items += kwds.items()
self._do_update(items)
def _do_update(self, items):
# Default implementation, can be overriden for speed
for k, v in items:
self[k] = v
def close(self):
"""
Release any system resources held by this object.
"""
def __enter__(self):
return self
def __exit__(self, *args):
self.close()
def close(z):
"""
Close *z* if possible.
"""
if hasattr(z, "close"):
z.close()
|