summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-09-21 16:59:12 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-09-21 16:59:12 +0000
commitf8953720c4438c34f5e42ca3949e8078ca777fe4 (patch)
tree93ec8608d5ec89c567114fc8b3baa3b5fc138dbc /ipalib
parent1ec4f379f5eb0b77e6ca90c777e2e976c28ddfca (diff)
downloadfreeipa-f8953720c4438c34f5e42ca3949e8078ca777fe4.tar.gz
freeipa-f8953720c4438c34f5e42ca3949e8078ca777fe4.tar.xz
freeipa-f8953720c4438c34f5e42ca3949e8078ca777fe4.zip
303: Removed Command.smart_option_order() method and moved its logic into Method.get_options()
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/public.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/ipalib/public.py b/ipalib/public.py
index a8397a54..40b13229 100644
--- a/ipalib/public.py
+++ b/ipalib/public.py
@@ -227,6 +227,7 @@ class Command(plugable.Plugin):
'smart_option_order',
'args',
'options',
+ 'params',
'args_to_kw',
'kw_to_args',
))
@@ -337,24 +338,15 @@ class Command(plugable.Plugin):
)
def __call__(self, *args, **kw):
- arg_kw = self.args_to_kw(*args)
- assert set(arg_kw).intersection(kw) == set()
- kw.update(arg_kw)
+ if len(args) > 0:
+ arg_kw = self.args_to_kw(*args)
+ assert set(arg_kw).intersection(kw) == set()
+ kw.update(arg_kw)
kw = self.normalize(**kw)
kw = self.convert(**kw)
kw.update(self.get_default(**kw))
self.validate(**kw)
- def smart_option_order(self):
- def get_key(option):
- if option.required:
- if option.default_from is None:
- return 0
- return 1
- return 2
- for option in sorted(self.options(), key=get_key):
- yield option
-
def args_to_kw(self, *values):
if self.max_args is not None and len(values) > self.max_args:
if self.max_args == 0:
@@ -463,8 +455,15 @@ class Method(Attribute, Command):
for option in self.takes_options:
yield option
if self.obj is not None and self.obj.Property is not None:
- for proxy in self.obj.Property():
- yield proxy.option
+ def get_key(p):
+ o = p.option
+ if o.required:
+ if o.default_from is None:
+ return 0
+ return 1
+ return 2
+ for prop in sorted(self.obj.Property(), key=get_key):
+ yield prop.option
class Property(Attribute):