From f29c827d06cb455709d3b07baf727913381709ca Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 18 Sep 2008 23:53:23 +0000 Subject: 301: Command.args_to_kw() now raises ArgumentError if more args than max_args are given --- ipalib/public.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ipalib/public.py') diff --git a/ipalib/public.py b/ipalib/public.py index c2624f67..967f88ce 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -388,6 +388,14 @@ class Command(plugable.Plugin): yield None def args_to_kw(self, *values): + if self.max_args is not None and len(values) > self.max_args: + if self.max_args == 0: + raise errors.ArgumentError(self, 'takes no arguments') + if self.max_args == 1: + raise errors.ArgumentError(self, 'takes at most 1 argument') + raise errors.ArgumentError(self, + 'takes at most %d arguments' % len(self.args) + ) return dict(self.__args_to_kw_iter(values)) def __args_to_kw_iter(self, values): -- cgit