MCPcopy Index your code
hub / github.com/aws/aws-cli / build_profile_map

Function build_profile_map

awscli/botocore/configloader.py:214–287  ·  view source on GitHub ↗

Convert the parsed INI config into a profile map. The config file format requires that every profile except the default to be prepended with "profile", e.g.:: [profile test] aws_... = foo aws_... = bar [profile bar] aws_... = foo aws_... = b

(parsed_ini_config)

Source from the content-addressed store, hash-verified

212
213
214def build_profile_map(parsed_ini_config):
215 """Convert the parsed INI config into a profile map.
216
217 The config file format requires that every profile except the
218 default to be prepended with "profile", e.g.::
219
220 [profile test]
221 aws_... = foo
222 aws_... = bar
223
224 [profile bar]
225 aws_... = foo
226 aws_... = bar
227
228 # This is *not* a profile
229 [preview]
230 otherstuff = 1
231
232 # Neither is this
233 [foobar]
234 morestuff = 2
235
236 The build_profile_map will take a parsed INI config file where each top
237 level key represents a section name, and convert into a format where all
238 the profiles are under a single top level "profiles" key, and each key in
239 the sub dictionary is a profile name. For example, the above config file
240 would be converted from::
241
242 {"profile test": {"aws_...": "foo", "aws...": "bar"},
243 "profile bar": {"aws...": "foo", "aws...": "bar"},
244 "preview": {"otherstuff": ...},
245 "foobar": {"morestuff": ...},
246 }
247
248 into::
249
250 {"profiles": {"test": {"aws_...": "foo", "aws...": "bar"},
251 "bar": {"aws...": "foo", "aws...": "bar"},
252 "preview": {"otherstuff": ...},
253 "foobar": {"morestuff": ...},
254 }
255
256 If there are no profiles in the provided parsed INI contents, then
257 an empty dict will be the value associated with the ``profiles`` key.
258
259 .. note::
260
261 This will not mutate the passed in parsed_ini_config. Instead it will
262 make a deepcopy and return that value.
263
264 """
265 parsed_config = copy.deepcopy(parsed_ini_config)
266 profiles = {}
267 sso_sessions = {}
268 services = {}
269 final_config = {}
270 for key, values in parsed_config.items():
271 if key.startswith("profile"):

Callers 1

load_configFunction · 0.85

Calls 2

_parse_sectionFunction · 0.85
updateMethod · 0.45

Tested by

no test coverage detected