Retrieves a config value from dict.
        If not found twrows an InvalidScanbooconfigException.
486043
def get(cls, key, section=None, **kwargs):
        
        section = section or cls._default_sect
        if section not in cls._conf:
            cls._load(section=section)

        value = cls._conf[section].get(key)

        # if not found in context read default
        if not value and section != cls._default_sect:
            value = cls._conf[cls._default_sect].get(key) if cls._default_sect in cls._conf else None

        if value is None:
            if 'default' in kwargs:  # behave as {}.get(x, default='fallback')
                _def_value = kwargs['default']
                logger.warn("Static configuration [{}] was not found. Using the default value [{}].".format(key, _def_value))
                return _def_value
            else:
                raise InvalidConfigException(u'Not found entry: {}'.format(key))

        try:
            value = from_json(value)  # parse value
        except (TypeError, ValueError):
            pass  # if not json parseable, then keep the string value

        return value
366145
def get_config_var_data(self, index, offset):
        """"""

        if index == 0 or index > len(self.config_database.entries):
            return [Error.INVALID_ARRAY_KEY, b'']

        entry = self.config_database.entries[index - 1]
        if not entry.valid:
            return [ConfigDatabaseError.OBSOLETE_ENTRY, b'']

        if offset >= len(entry.data):
            return [Error.INVALID_ARRAY_KEY, b'']

        data_chunk = entry.data[offset:offset + 16]
        return [Error.NO_ERROR, data_chunk]
675361
def get_model_config_value(self, obj, name):
        """"""
        config = models_config.get_config(obj)
        return getattr(config, name)
1094036
def get_configuration(filename):
    
    logger.debug('Reading configuration from {}'.format(filename))
    conf = SafeConfigParser()
    conf.read(filename)

    if not conf:
        logger.error('Configuration file {} not found'.format(filename))
        sys.exit(1)

    if not conf.has_section('general'):
        logger.error('Missing [general] section in the configuration file')
        sys.exit(1)

    try:
        config = {
            'access-key-id': conf.get('general', 'access-key-id'),
            'secret-access-key': conf.get('general', 'secret-access-key'),
            'region': conf.get('general', 'region'),
        }
    except NoOptionError as err:
        logger.error('Error in config file: {}'.format(err))
        sys.exit(1)

    return config
834478
def config_(cls, key, default=None):
        
        return cls._app.config.get(key, default)
813692
def read_config(*args):
    '''
    
    '''

    ret = {}
    if _TRAFFICCTL:
        cmd = _traffic_ctl('config', 'get')
    else:
        cmd = _traffic_line('-r')

    try:
        for arg in args:
            log.debug('Querying: %s', arg)
            ret[arg] = _subprocess(cmd + [arg])
    except KeyError:
        pass

    return ret
1206367
def _verify_config_dict(self, valid, config, dev_os, key_path=None):
        '''
        
        '''
        if not key_path:
            key_path = []
        for key, value in valid.items():
            self._verify_config_key(key, value, valid, config, dev_os, key_path)
460412
def get_config_item(self, key):
        
        value = _lxc.Container.get_config_item(self, key)

        if value is False:
            return False
        elif value.endswith("\n"):
            return value.rstrip("\n").split("\n")
        else:
            return value
550975
def getEmbeddedKeyVal(cfgFileName, kwdName, dflt=None):
    
    # Assume this is a ConfigObj file.  Use that s/w to quickly read it and
    # put it in dict format.  Assume kwd is at top level (not in a section).
    # The input may also be a .cfgspc file.
    #
    # Only use ConfigObj here as a tool to generate a dict from a file - do
    # not use the returned object as a ConfigObj per se.  As such, we can call
    # with "simple" format, ie. no cfgspc, no val'n, and "list_values"=False.
    try:
        junkObj = configobj.ConfigObj(cfgFileName, list_values=False)
    except:
        if kwdName == TASK_NAME_KEY:
            raise KeyError('Can not parse as a parameter config file: '+ \
                           '\n\t'+os.path.realpath(cfgFileName))
        else:
            raise KeyError('Unfound key "'+kwdName+'" while parsing: '+ \
                           '\n\t'+os.path.realpath(cfgFileName))

    if kwdName in junkObj:
        retval = junkObj[kwdName]
        del junkObj
        return retval
    # Not found
    if dflt is not None:
        del junkObj
        return dflt
    else:
        if kwdName == TASK_NAME_KEY:
            raise KeyError('Can not parse as a parameter config file: '+ \
                           '\n\t'+os.path.realpath(cfgFileName))
        else:
            raise KeyError('Unfound key "'+kwdName+'" while parsing: '+ \
                           '\n\t'+os.path.realpath(cfgFileName))
266311
def get_config_value(config_file, section, variable):
    
    try:
        parser = ConfigParser.SafeConfigParser()
        parser.read(config_file)
        return parser.get(section, variable)
    except:
        return None
622625
def parse_config(config_file=None):
    '''
    
    '''
    if config_file is None:
        config_file = _config_file()
    ret = {}
    if _check_config_exists(config_file):
        with salt.utils.files.fopen(config_file) as ifile:
            for line in ifile:
                key, val = salt.utils.stringutils.to_unicode(line).split('=')
                ret[key] = val
        return ret

    return 'Could not find {0} on file system'.format(config_file)
98795
def get_config():
    
    p = Path('.travis.yml')
    if not p.exists():
        return {}
    with p.open() as f:
        travis_config = yaml.safe_load(f.read())

    config = travis_config.get('doctr', {})

    if not isinstance(config, dict):
        raise ValueError('config is not a dict: {}'.format(config))
    return config
796026
def get_value(repo_directory, key, expect_type=None):
    """"""
    config = read_config(repo_directory)
    value = config.get(key)
    if expect_type and value is not None and not isinstance(value, expect_type):
        raise ConfigSchemaError('Expected config variable %s to be type %s, got %s'
            % (repr(key), repr(expect_type), repr(type(value))))
    return value
763067
def get_config(config_path):
    """"""
    if not os.path.exists(config_path):
        raise ConfigDoesNotExistException

    logger.debug('config_path is {0}'.format(config_path))
    with io.open(config_path, encoding='utf-8') as file_handle:
        try:
            yaml_dict = poyo.parse_string(file_handle.read())
        except poyo.exceptions.PoyoException as e:
            raise InvalidConfiguration(
                'Unable to parse YAML file {}. Error: {}'
                ''.format(config_path, e)
            )

    config_dict = merge_configs(DEFAULT_CONFIG, yaml_dict)

    raw_replay_dir = config_dict['replay_dir']
    config_dict['replay_dir'] = _expand_path(raw_replay_dir)

    raw_cookies_dir = config_dict['cookiecutters_dir']
    config_dict['cookiecutters_dir'] = _expand_path(raw_cookies_dir)

    return config_dict
1190747
def _get_config(config_file):
    ''''''
    parser = ConfigParser.SafeConfigParser()
    if os.path.lexists(config_file):
        try:
            log.info('Reading config: %s', config_file)
            inp = open(config_file)
            parser.readfp(inp)
            return parser
        except (IOError, ConfigParser.ParsingError), err:
            raise ConfigError("Failed to read configuration %s\n%s" % (config_file, err))
    return None
16282
def from_dict(cls, d):
        
        conf = {}
        for k in d["config"]:
            v = d["config"][k]
            if isinstance(v, dict):
                conf[str(k)] = get_dict_handler(d["config"]["type"])(v)
            else:
                conf[str(k)] = v
        return get_class(str(d["class"]))(config=conf)
117356
def get_config_value(name, path_to_file='config.txt'):
    

    # if the function is called from gui then the file has to be located with respect to the gui folder
    if not os.path.isfile(path_to_file):
        path_to_file = os.path.join('../instruments/', path_to_file)

    path_to_file = os.path.abspath(path_to_file)

    if not os.path.isfile(path_to_file):
        print(('path_to_file', path_to_file))
        #raise IOError('{:s}: config file is not valid'.format(path_to_file))
        return None

    f = open(path_to_file, 'r')
    string_of_file_contents = f.read()

    if name[-1] is not ':':
        name += ':'

    if name not in string_of_file_contents:
        return None
    else:
        config_value = [line.split(name)[1] for line in string_of_file_contents.split('\n')
                        if len(line.split(name)) > 1][0].strip()
        return config_value