1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

samba-tool: give cache_loader pseudo-dict a .get() method

This makes it more dict-like, and makes the next patch (adding
samba-tool help) simpler.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall 2017-12-21 11:30:24 +13:00 committed by Andrew Bartlett
parent cef83c0cc6
commit 769197dfa3

View File

@ -36,6 +36,12 @@ class cache_loader(dict):
'cmd_%s' % attr)()
return dict.__getitem__(self, attr)
def get(self, attr, default=None):
try:
return self[attr]
except KeyError:
return default
def iteritems(self):
for key in self:
yield (key, self[key])