MCPcopy
hub / github.com/awslabs/aws-shell / load

Method load

awsshell/config.py:24–45  ·  view source on GitHub ↗

Read the config file if it exists, else read the default config. Creates the user config file if it doesn't exist using the template. :type config_template: str :param config_template: The config template file name. :type config_file: str :param config_file

(self, config_template, config_file=None)

Source from the content-addressed store, hash-verified

22 """Reads and writes the config template and user config file."""
23
24 def load(self, config_template, config_file=None):
25 """Read the config file if it exists, else read the default config.
26
27 Creates the user config file if it doesn't exist using the template.
28
29 :type config_template: str
30 :param config_template: The config template file name.
31
32 :type config_file: str
33 :param config_file: (Optional) The config file name.
34 If None, the config_file name will be set to the config_template.
35
36 :rtype: :class:`configobj.ConfigObj`
37 :return: The config information for reading and writing.
38 """
39 if config_file is None:
40 config_file = config_template
41 config_path = build_config_file_path(config_file)
42 template_path = os.path.join(os.path.dirname(__file__),
43 config_template)
44 self._copy_template_to_config(template_path, config_path)
45 return self._load_template_or_config(template_path, config_path)
46
47 def _load_template_or_config(self, template_path, config_path):
48 """Load the config file if it exists, else read the default config.

Callers 2

load_configMethod · 0.95
load_indexMethod · 0.80

Calls 3

build_config_file_pathFunction · 0.90

Tested by

no test coverage detected