Refactoring the sdc-BE-init python scripts
[sdc.git] / catalog-be / src / main / resources / scripts / sdcBePy / tosca / models / normativeToUpdateList.py
1 import json
2
3 from sdcBePy.tosca.models.normativeTypeCandidate import NormativeTypeCandidate
4
5
6 class TypesToUpdate:
7
8     def __init__(self, files):
9         self.types_list = {}
10         self.load_files(files)
11
12     def load_files(self, files):
13         for file in files:
14             with open(file, 'r') as stream:
15                 _types = json.load(stream)
16                 for type_key, type_value in _types.items():
17                     self.types_list[type_key] = type_value
18
19     def get_type(self, key):
20         return self.types_list[key]
21
22
23 def get_heat_and_normative_to_update_list(types, base_file_location):
24     return [
25         get_heat(types, base_file_location),
26         get_normative(types, base_file_location)
27     ]
28
29
30 def get_nfv_onap_sol_to_update_list(types, base_file_location):
31     return [
32         get_nfv(types, base_file_location),
33         get_onap(types, base_file_location),
34         get_sol(types, base_file_location)
35     ]
36
37
38 def get_heat(types, base_location="/"):
39     return NormativeTypeCandidate(base_location + "heat-types/",
40                                   types.get_type("heat"))
41
42
43 def get_normative(types, base_location="/"):
44     return NormativeTypeCandidate(base_location + "normative-types/",
45                                   types.get_type("normative"))
46
47
48 def get_nfv(types, base_location="/"):
49     return NormativeTypeCandidate(base_location + "nfv-types/",
50                                   types.get_type("nfv"))
51
52
53 def get_onap(types, base_location="/"):
54     return NormativeTypeCandidate(base_location + "onap-types/",
55                                   types.get_type("onap"))
56
57
58 def get_sol(types, base_location="/"):
59     return NormativeTypeCandidate(base_location + "sol-types/",
60                                   types.get_type("sol"))