summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>2017-12-21 11:30:24 +1300
committerAndrew Bartlett <abartlet@samba.org>2017-12-22 03:30:12 +0100
commit769197dfa320ce9d252c0871df0ceb3c47fb644b (patch)
tree4a1cdf8366113253bfe5afc87f4947564a34d2b8 /python
parentcef83c0cc60359935fc4fa5db60cdc825bd3fa25 (diff)
downloadsamba-769197dfa320ce9d252c0871df0ceb3c47fb644b.tar.gz
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>
Diffstat (limited to 'python')
-rw-r--r--python/samba/netcmd/main.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/python/samba/netcmd/main.py b/python/samba/netcmd/main.py
index ba9074843ec..cc16e4a3fe5 100644
--- a/python/samba/netcmd/main.py
+++ b/python/samba/netcmd/main.py
@@ -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])