Path: blob/develop/awscli/customizations/configure/__init__.py
1567 views
# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.1#2# Licensed under the Apache License, Version 2.0 (the "License"). You3# may not use this file except in compliance with the License. A copy of4# the License is located at5#6# http://aws.amazon.com/apache2.0/7#8# or in the "license" file accompanying this file. This file is9# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF10# ANY KIND, either express or implied. See the License for the specific11# language governing permissions and limitations under the License.12import string13from awscli.compat import shlex1415NOT_SET = '<not set>'16PREDEFINED_SECTION_NAMES = ('preview', 'plugins')17_WHITESPACE = ' \t'181920class ConfigValue(object):2122def __init__(self, value, config_type, config_variable):23self.value = value24self.config_type = config_type25self.config_variable = config_variable2627def mask_value(self):28if self.value is NOT_SET:29return30self.value = mask_value(self.value)313233class SectionNotFoundError(Exception):34pass353637def mask_value(current_value):38if current_value is None:39return 'None'40else:41return ('*' * 16) + current_value[-4:]424344def profile_to_section(profile_name):45"""Converts a profile name to a section header to be used in the config."""46if any(c in _WHITESPACE for c in profile_name):47profile_name = shlex.quote(profile_name)48return 'profile %s' % profile_name495051