samba.netcmd: Reintroduce Command.name.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 13 Oct 2011 21:16:58 +0000 (23:16 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 13 Oct 2011 22:22:57 +0000 (00:22 +0200)
source4/scripting/python/samba/netcmd/__init__.py
source4/scripting/python/samba/tests/netcmd.py

index 19fae071c6db0aa3d1e937d2e3ba9f6adb5bac77..ad6e688da81a52353743730861eb0e1c8aaba18d 100644 (file)
@@ -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
index 4f06124482b56909a5cfea8f41804caf703d2afe..ac5164b47924ac8197b478c416c264d7449cef2f 100644 (file)
@@ -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)