]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybing/mgr/mgr_module: extract method for collecting kwargs
authorKefu Chai <kchai@redhat.com>
Sat, 26 Dec 2020 12:07:46 +0000 (20:07 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 14 Jan 2021 11:46:04 +0000 (19:46 +0800)
the existing method is using argdesc for collecting kwargs, by
extracting into a separated method, we can use the annotation as an
alternative.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/mgr_module.py

index 35a6421fa3aeacee65ed274933d96086eaa57b79..437f9e5837a5f8620484f7724c0a90fc50c08b13 100644 (file)
@@ -328,7 +328,7 @@ class CLICommand(object):
             k, v = key, val
         return kwargs_switch, k.replace('-', '_'), v
 
-    def call(self, mgr, cmd_dict, inbuf):
+    def _collect_args(self, cmd_dict):
         kwargs = {}
         kwargs_switch = False
         for a, d in self.args_dict.items():
@@ -336,6 +336,10 @@ class CLICommand(object):
                 continue
             kwargs_switch, k, v = self._get_arg_value(kwargs_switch, a, cmd_dict[a])
             kwargs[k] = v
+        return kwargs
+
+    def call(self, mgr, cmd_dict, inbuf):
+        kwargs = self._collect_args(cmd_dict)
         if inbuf:
             kwargs['inbuf'] = inbuf
         assert self.func