Robot Framework Integrated Development Environment (RIDE)
arguments.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 import re
17 
18 from ..robotapi import is_dict_var, is_list_var, is_scalar_var
19 from ..utils import variablematcher
20 
21 default_val_regexp = re.compile(r'([$]\{.*\})\s*=\s*(.*)')
22 
23 
25  result = {}
26  for arg in args:
27  name, value = parse_argument(arg)
28  if name:
29  result[name] = value
30  if not args and name:
31  for var in variablematcher.find_variable_basenames(name):
32  if variablematcher.is_scalar_variable(var):
33  result[var] = None
34  return result
35 
36 
37 def parse_argument(argument):
38  match = default_val_regexp.match(argument)
39  if match:
40  return (match.group(1), match.group(2))
41  elif is_scalar_var(argument):
42  return argument, ''
43  elif is_list_var(argument):
44  return argument, []
45  elif is_dict_var(argument):
46  return argument, {}
47  else:
48  return None, None
def parse_argument(argument)
Definition: arguments.py:37
def parse_arguments_to_var_dict(args, name)
Definition: arguments.py:24