MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / _parse_fields

Function _parse_fields

examples/pam_import_generator_v2.py:118–151  ·  view source on GitHub ↗
(obj: Dict, type: str, tmpl=None)

Source from the content-addressed store, hash-verified

116
117
118def _parse_fields(obj: Dict, type: str, tmpl=None):
119 templates = {
120 "rs":{
121 "title":"",
122 "host":"",
123 "type":"pamMachine",
124 "pam_settings": {
125 "options": {
126 "rotation": "off",
127 "connections": "on",
128 "tunneling": "off",
129 "graphical_session_recording": "on"
130 },
131 "connection":{}
132 },
133 "users": []
134 },
135 "usr":{
136 "rotation_settings": {}
137 }
138 }
139 res = copy.deepcopy(tmpl) if tmpl else copy.deepcopy(templates.get(type, {}))
140
141 for key in obj:
142 if obj[key] == "": continue
143 if key.startswith(type):
144 split_arg = key.split(".")
145 if len(split_arg)==2:
146 res[split_arg[1]] = obj[key]
147 elif len(split_arg)==3:
148 res[split_arg[1]][split_arg[2]] = obj[key]
149 elif len(split_arg)==4:
150 res[split_arg[1]][split_arg[2]][split_arg[3]] = obj[key]
151 return res
152
153
154def _gen_data(csv_data: List[Dict[str, str]],

Callers 1

_gen_dataFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected