in bonsaicli2/bonsai_cli/config.py [0:0]
def _parse_config(self, profile: Optional[str]):
"""parse both the '~/.bonsaiconfig' and './.bonsaiconfig' config files."""
# read the values
def assign_key(key: str):
if self._config_parser.has_option(section, key):
if key.lower() == _USE_COLOR.lower():
self.__dict__[key] = self._config_parser.getboolean(section, key)
else:
self.__dict__[key] = self._config_parser.get(section, key)
# get the profile
section = _DEFAULT
if profile is None:
if self._config_parser.has_option(_DEFAULT, _PROFILE):
section = self._config_parser.get(_DEFAULT, _PROFILE)
self.profile = section
else:
section = profile
assign_key(_ACCESSKEY)
assign_key(_WORKSPACEID)
assign_key(_TENANTID)
assign_key(_URL)
assign_key(_GATEWAYURL)
assign_key(_USE_COLOR)
# if url is none set it to default bonsai api url
if self.url is None:
self.url = _DEFAULT_URL
elif not urlparse(self.url).scheme:
# if no url scheme is supplied, assume https
self.url = "https://{}".format(self.url)