Commit ee7c74fb authored by Jelte Jansen's avatar Jelte Jansen
Browse files

positional arguments for bigtool; if the command arguments are not in 'name =...

positional arguments for bigtool; if the command arguments are not in 'name = value' pairs, the arguments are parsed based on their position. The parser then adds the names again (so for the application the params is still a {name:value} dict

git-svn-id: svn:// e5f2f494-b856-4b98-b285-d166d9295462
parent 7e2512b0
......@@ -60,13 +60,33 @@ class BigTool(Cmd):
raise CmdUnknownParamSyntaxError(cmd.module, cmd.command,
elif params:
param_name = None
for name in params:
if not name in all_params:
# either the name of the parameter must be known, or
# the 'name' must be an integer (ie. the position of
# an unnamed argument
if type(name) == int:
# (-1, help is always in the all_params list)
if name >= len(all_params) - 1:
# add to last known param
if param_name:
cmd.params[param_name] += cmd.params[name]
raise CmdUnknownParamSyntaxError(cmd.module, cmd.command, cmd.params[name])
# replace the numbered items by named items
param_name = command_info.get_param_name_by_position(name+1)
cmd.params[param_name] = cmd.params[name]
del cmd.params[name]
elif not name in all_params:
raise CmdUnknownParamSyntaxError(cmd.module, cmd.command, name)
param_nr = 0
for name in manda_params:
if not name in params:
if not name in params and not param_nr in params:
raise CmdMissParamSyntaxError(cmd.module, cmd.command, name)
param_nr += 1
def _handle_cmd(self, cmd):
#to do, consist xml package and send to bind10
......@@ -72,7 +72,7 @@ class BigToolCmd:
if param and'name') == "help":
self.params["help"] = "help"
while True:
if not param_text.strip():
......@@ -80,9 +80,16 @@ class BigToolCmd:
groups = PARAM_PATTERN.match(param_text) or \
if not groups:
raise CmdParamFormatError(self.module, self.command)
if not groups:
#raise CmdParamFormatError(self.module, self.command)
# ok, fill in the params in the order entered
params = re.findall("([^\" ]+|\".*\")", param_text)
i = 0
for p in params:
self.params[i] = p
i += 1
self.params['param_name')] ='param_value')
param_text ='next_params')
if not param_text or (not param_text.strip()):
......@@ -81,7 +81,17 @@ class CommandInfo:
return [name for name in all_names
if not self.params[name].is_optional]
def get_param_name_by_position(self, pos):
if type(pos) == int:
i = 0
for k in self.params.keys():
if i == pos:
return k
i += 1
raise KeyError(str(pos) + " out of range")
raise KeyError(str(pos) + " is not an integer")
def need_instance_param(self):
return self.need_inst_param
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 to comment