1 # Copyright 2019 AT&T Intellectual Property. All rights reserved.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 from robot.libraries.BuiltIn import BuiltIn
18 class VariableHelper(object):
19 """ Non keyword class for useful for working with varaibles """
22 super(VariableHelper, self).__init__()
23 self.builtin = BuiltIn()
25 def get_globally_injected_parameters(self):
26 dictionary = self.builtin.get_variables(no_decoration=True)
27 return self.filter_variables_by_key_prefix(dictionary, "GLOBAL_INJECTED_")
29 def get_global_parameters(self):
30 dictionary = self.builtin.get_variables(no_decoration=True)
31 global_variables = self.filter_variables_by_key_prefix(dictionary, "GLOBAL_")
32 # strip out global injected (get those above)
33 for key in self.get_globally_injected_parameters():
34 del global_variables[key]
35 return global_variables
38 def filter_variables_by_key_prefix(dictionary, partial):
40 for key, val in dictionary.items():
41 if key.startswith(partial):