Commit 3032b9c0 by Őry Máté

check mandatory command arguments

parent 6518fe6a
...@@ -367,6 +367,16 @@ class SerialLineReceiver(SerialLineReceiverBase): ...@@ -367,6 +367,16 @@ class SerialLineReceiver(SerialLineReceiverBase):
if unexpected_kwargs: if unexpected_kwargs:
raise TypeError("Command got unexpected keyword arguments: " raise TypeError("Command got unexpected keyword arguments: "
"%s" % ", ".join(unexpected_kwargs)) "%s" % ", ".join(unexpected_kwargs))
if argspec.defaults:
mandatory_args = argspec.args[0:-len(argspec.defaults)]
else:
mandatory_args = argspec.args
missing_kwargs = set(mandatory_args) - set(args)
if missing_kwargs:
raise TypeError("Command %s missing arguments: %s" % (
unicode(func), ", ".join(missing_kwargs)))
return func return func
def handle_command(self, command, args): def handle_command(self, command, args):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment