azure-cli-dev-tools/azdev/utilities/config.py

34 строки
1.1 KiB
Python
Исходник Постоянная ссылка Обычный вид История

2019-01-11 19:39:17 +03:00
# -----------------------------------------------------------------------------
2018-11-21 02:46:13 +03:00
# Copyright (c) Microsoft Corporation. All rights reserved.
2019-01-11 19:39:17 +03:00
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# -----------------------------------------------------------------------------
2018-11-21 02:46:13 +03:00
import os
from knack.config import CLIConfig
2018-11-21 02:46:13 +03:00
def get_azdev_config():
return CLIConfig(config_dir=get_azdev_config_dir(), config_env_var_prefix='AZDEV')
def get_azure_config():
return CLIConfig(config_dir=get_azure_config_dir(), config_env_var_prefix='AZURE')
def get_azdev_config_dir():
""" Returns the user's .azdev directory. """
from azdev.utilities import get_env_path
env_name = None
_, env_name = os.path.splitdrive(get_env_path())
azdev_dir = os.getenv('AZDEV_CONFIG_DIR', None) or os.path.expanduser(os.path.join('~', '.azdev'))
if not env_name:
return azdev_dir
return os.path.join(azdev_dir, 'env_config') + env_name
2018-11-21 02:46:13 +03:00
def get_azure_config_dir():
""" Returns the user's Azure directory. """
return os.getenv('AZURE_CONFIG_DIR', None) or os.path.expanduser(os.path.join('~', '.azure'))