Coverage for src/robotide/controller/arguments.py: 95%
26 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
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.
16import re 1ST
18from ..robotapi import is_dict_var, is_list_var, is_scalar_var 1ST
19from ..utils import variablematcher 1ST
21default_val_regexp = re.compile(r'([$]\{.*\})\s*=\s*(.*)') 1ST
24def parse_arguments_to_var_dict(args, name): 1ST
25 result = {} 1QIRaVWXYZ012hijJKLMNOPklmnopqrstuvbwxyzABCDEFGcdeHfg
26 for arg in args: 1QIRaVWXYZ012hijJKLMNOPklmnopqrstuvbwxyzABCDEFGcdeHfg
27 name, value = parse_argument(arg) 1IahijJKLMNOPklmnopqrstuvbwxyzABCDEFGcdeHfg
28 if name: 1IahijJKLMNOPklmnopqrstuvbwxyzABCDEFGcdeHfg
29 result[name] = value 1IahijJKLMNOPklmnopqrstuvbwxyzABCDEFGcdeHfg
30 if not args and name: 1QIRaVWXYZ012hijJKLMNOPklmnopqrstuvbwxyzABCDEFGcdeHfg
31 for var in variablematcher.find_variable_basenames(name): 1QRVWXYZ012
32 if variablematcher.is_scalar_variable(var): 1QR
33 result[var] = None 1QR
34 return result 1QIRaVWXYZ012hijJKLMNOPklmnopqrstuvbwxyzABCDEFGcdeHfg
37def parse_argument(argument): 1ST
38 match = default_val_regexp.match(argument) 1567U34IahijJKLMNOPklmnopqrstuvbwxyzABCDEFGcdeHfg
39 if match: 1567U34IahijJKLMNOPklmnopqrstuvbwxyzABCDEFGcdeHfg
40 return (match.group(1), match.group(2)) 1567aklmnopqrstuvbwxyzABCDEFGcdeHfg
41 elif is_scalar_var(argument): 1U34IahijJKLMNOPklmnopqrstuvbwxyzABCDEFGcdeHfg
42 return argument, '' 14IahijJKLMNOPklmnopqrstuvbwxyzABCDEFGcdeHfg
43 elif is_list_var(argument): 1U3ahijbcdefg
44 return argument, [] 13ahijbcdefg
45 elif is_dict_var(argument): 45 ↛ 46line 45 didn't jump to line 46 because the condition on line 45 was never true1Ua
46 return argument, {}
47 else:
48 return None, None 1Ua