in alibabacloud_credentials/providers.py [0:0]
def parse_ini(self):
file_path = self.file_path if self.file_path else au.environment_credentials_file
if file_path is None:
if not ac.HOME:
return
if os.path.exists(os.path.join(ac.HOME, "/.alibabacloud/credentials.ini")):
# Support '/.alibabacloud/credentials.ini' is due to historical mistakes.
# Please try to use '~/.alibabacloud/credentials.ini'.
file_path = os.path.join(ac.HOME, "/.alibabacloud/credentials.ini")
elif os.path.exists(os.path.join(ac.HOME, ".alibabacloud/credentials.ini")):
file_path = os.path.join(ac.HOME, ".alibabacloud/credentials.ini")
if file_path is None:
return
elif len(file_path) == 0:
raise CredentialException("The specified credentials file is empty")
# loads ini
conf = configparser.ConfigParser()
conf.read(file_path, encoding='utf-8')
ini_map = dict(conf._sections)
for k in dict(conf._sections):
option = dict(ini_map[k])
for key, value in dict(ini_map[k]).items():
if '#' in value:
option[key] = value.split('#')[0].strip()
else:
option[key] = value.strip()
ini_map[k] = option
client_config = ini_map.get(au.client_type)
return client_config