コード例 #1
0
def print_key(config_path, key, type_name):
    config = read_config(config_path)
    keys = key.split('.')
    for key in keys:
        try:
            config = config[key]
        except KeyError:
            raise KeyError('key %s does not exist in %s' % (key, config_path))
    ensure_type(config, type_name)
    print config
コード例 #2
0
def print_key(config_path, key, type_name, default=None):
    config = read_config(config_path)
    keys = key.split('.')
    for key in keys:
        try:
            config = config[key]
        except KeyError:
            if default is not None:
                print default
                return
            else:
                raise ConfigException(
                    'key %s does not exist in %s' % (key, config_path))
    ensure_type(config, type_name)
    print config
コード例 #3
0
def print_key(config_path, key, type_name, default=None):
    config = read_config(config_path)
    keys = key.split('.')
    for key in keys:
        try:
            config = config[key]
        except KeyError:
            if default is not None:
                print default
                return
            else:
                raise ConfigException('key %s does not exist in %s' %
                                      (key, config_path))
    ensure_type(config, type_name)
    print config