remove the 200 for sdc too
[testsuite/python-testing-utils.git] / robotframework-onap / ONAPLibrary / VariableHelper.py
1 # Copyright 2019 AT&T Intellectual Property. All rights reserved.
2 #
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
6 #
7 #         http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14
15 from robot.libraries.BuiltIn import BuiltIn
16
17
18 class VariableHelper(object):
19     """ Non keyword class for useful for working with varaibles """
20
21     def __init__(self):
22         super(VariableHelper, self).__init__()
23         self.builtin = BuiltIn()
24
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_")
28
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
36
37     @staticmethod
38     def filter_variables_by_key_prefix(dictionary, partial):
39         matches = dict()
40         for key, val in dictionary.items():
41             if key.startswith(partial):
42                 matches[key] = val
43         return matches