summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/scripting/python/samba/netcmd/__init__.py8
-rw-r--r--source4/scripting/python/samba/tests/netcmd.py5
2 files changed, 13 insertions, 0 deletions
diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py
index 19fae071c6..ad6e688da8 100644
--- a/source4/scripting/python/samba/netcmd/__init__.py
+++ b/source4/scripting/python/samba/netcmd/__init__.py
@@ -45,6 +45,14 @@ class Command(object):
full_description = property(_get_full_description)
+ def _get_name(self):
+ name = self.__class__.__name__
+ if name.startswith("cmd_"):
+ return name[4:]
+ return name
+
+ name = property(_get_name)
+
# synopsis must be defined in all subclasses in order to provide the
# command usage
synopsis = None
diff --git a/source4/scripting/python/samba/tests/netcmd.py b/source4/scripting/python/samba/tests/netcmd.py
index 4f06124482..ac5164b479 100644
--- a/source4/scripting/python/samba/tests/netcmd.py
+++ b/source4/scripting/python/samba/tests/netcmd.py
@@ -56,3 +56,8 @@ class CommandTests(samba.tests.TestCase):
class cmd_foo(Command):
"""Mydescription"""
self.assertEquals("Mydescription", cmd_foo().description)
+
+ def test_name(self):
+ class cmd_foo(Command):
+ pass
+ self.assertEquals("foo", cmd_foo().name)