.. warning::
        This function is deprecated, please use :py:class:`SystemdConf` instead.

    Function to parse config format file, the result format is dictionary.
774284
def parse_systemd_ini(content):
    

    deprecated(parse_systemd_ini, "Use the `SystemdConf` class instead.")

    doc = parse_doc(content)

    dict_all = {}
    for section in doc:
        section_dict = {}
        option_names = set(o.name for o in section)
        for name in option_names:
            options = [str(o.value) for o in section[name]]
            section_dict[name] = options[0] if len(options) == 1 else options
        dict_all[section.name] = section_dict

    return dict_all
6400
def defconfig_filename(self):
        
        if self.defconfig_list:
            for filename, cond in self.defconfig_list.defaults:
                if expr_value(cond):
                    try:
                        with self._open_config(filename.str_value) as f:
                            return f.name
                    except IOError:
                        continue

        return None
943800
def config_function(self, token):
        
        match = token["match"]
        function = match.group(2).lower()
        param = match.group(3) or ""
        value_type = match.group(6) or "auto"

        # fix any escaped closing parenthesis
        param = param.replace(r"\)", ")")

        CONFIG_FUNCTIONS = {
            "base64": self.make_function_value_private,
            "env": self.make_value_from_env,
            "hide": self.make_function_value_private,
            "shell": self.make_value_from_shell,
        }

        return CONFIG_FUNCTIONS[function](param, value_type, function)
786932
function _configFilter ( f ) {
        var parts = f.split("."),
            ext = parts[ parts.length - 1 ],
            pre = parts[ parts.length - 2 ],
            name = parts[ parts.length - 3];

        return !!(ext === "dist" && pre === "json" &&
                    exports.__ignores.indexOf( name ) === -1 && exports.__ignores.indexOf( f ) === -1 );
    }
842129
def filesystem_from_config_dict(config_fs):
    
    if "module" not in config_fs:
        print("Key 'module' should be defined for the filesystem provider ('fs' configuration option)", file=sys.stderr)
        exit(1)

    filesystem_providers = get_filesystems_providers()
    if config_fs["module"] not in filesystem_providers:
        print("Unknown filesystem provider "+config_fs["module"], file=sys.stderr)
        exit(1)

    fs_class = filesystem_providers[config_fs["module"]]
    fs_args_needed = fs_class.get_needed_args()

    fs_args = {}
    for arg_name, (arg_type, arg_required, _) in fs_args_needed.items():
        if arg_name in config_fs:
            fs_args[arg_name] = arg_type(config_fs[arg_name])
        elif arg_required:
            print("fs option {} is required".format(arg_name), file=sys.stderr)
            exit(1)

    try:
        return fs_class.init_from_args(**fs_args)
    except:
        print("Unable to load class " + config_fs["module"], file=sys.stderr)
        raise
846565
def get_conf_update(self):
        
        dyn_conf = self.get_collection_rules()

        if not dyn_conf:
            return self.get_conf_file()

        version = dyn_conf.get('version', None)
        if version is None:
            raise ValueError("ERROR: Could not find version in json")

        dyn_conf['file'] = self.collection_rules_file
        logger.debug("Success reading config")
        config_hash = hashlib.sha1(json.dumps(dyn_conf).encode('utf-8')).hexdigest()
        logger.debug('sha1 of config: %s', config_hash)
        return dyn_conf
701617
def dict_conf(filename):
  

  f, ext = os.path.splitext(filename)
  ext = ext.lower()

  if ext == "conf" or ext == "ini":
    # python config via config parser

    config = ConfigParser()
    config.optionxform=str
    config.read(filename)
    rv = {}
    for section in config.sections():
      rv[section] = {}
      for key,value in config.items(section):
        rv[section][key] = value.strip('"').strip("'").decode("string_escape")
    return rv
  else:
    # other type of config, use munge
    if munge_config:
      src = munge_config.parse_url(filename)
      return src.cls().load(open(filename)).get("vodka")
    else:
      raise Exception("'%s' type of config encountered, install munge" % ext)
497035
def get_config_value_from_file(key, config_path=None, default=None):
    
    config = _get_config_dict_from_file(config_path)
    if key not in config:
        return default
    return config[key]
878621
def read_config(config_fname=None):
    """"""

    if not config_fname:
        config_fname = DEFAULT_CONFIG_FNAME

    try:
        with open(config_fname, 'r') as config_file:
            config = yaml.load(config_file)
    except IOError as exc:
        if exc.errno == errno.ENOENT:
            print('payu: warning: Configuration file {0} not found!'
                  .format(config_fname))
            config = {}
        else:
            raise

    collate_config = config.pop('collate', {})

    # Transform legacy collate config options
    if type(collate_config) is bool:
        collate_config = {'enable': collate_config}

    collatestr = 'collate_'
    foundkeys = []
    # Cycle through old collate config and convert to newer dict format
    for key in list(config.keys()):
        if key.startswith(collatestr):
            foundkeys.append(key)
            collate_config[key[len(collatestr):]] = config.pop(key)
    if foundkeys:
        print("Use of these keys is deprecated: {}.".format(
                ", ".join(foundkeys)))
        print("Instead use collate dictionary and subkey "
              "without 'collate_' prefix")

    config['collate'] = collate_config

    return config
654014
def config_file(kind="local"):
    
    if kind == 'local':
        return 'setup.cfg'
    if kind == 'global':
        return os.path.join(
            os.path.dirname(distutils.__file__), 'distutils.cfg'
        )
    if kind == 'user':
        dot = os.name == 'posix' and '.' or ''
        return os.path.expanduser(convert_path("~/%spydistutils.cfg" % dot))
    raise ValueError(
        "config_file() type must be 'local', 'global', or 'user'", kind
    )
954092
def set_system_conf(self, key=None, value=None, d=None):
        
        if isinstance(d, dict):
            self._system.update(d)
        elif isinstance(key, str) and isinstance(value, str):
            self._system[key] = value
        else:
            raise TypeError("key, value must be strings")
102056
def conf_from_dict(conf_dict):
    '''
    
    '''
    conf = Config(filename=conf_dict.get('__file__', ''))

    for k, v in six.iteritems(conf_dict):
        if k.startswith('__'):
            continue
        elif inspect.ismodule(v):
            continue

        conf[k] = v
    return conf
1213487
def config():
    '''
    
    '''
    if 'conf_file' not in __opts__:
        return {}
    if os.path.isdir(__opts__['conf_file']):
        if salt.utils.platform.is_proxy():
            gfn = os.path.join(
                    __opts__['conf_file'],
                    'proxy.d',
                    __opts__['id'],
                    'grains'
                    )
        else:
            gfn = os.path.join(
                    __opts__['conf_file'],
                    'grains'
                    )
    else:
        if salt.utils.platform.is_proxy():
            gfn = os.path.join(
                    os.path.dirname(__opts__['conf_file']),
                    'proxy.d',
                    __opts__['id'],
                    'grains'
                    )
        else:
            gfn = os.path.join(
                    os.path.dirname(__opts__['conf_file']),
                    'grains'
                    )
    if os.path.isfile(gfn):
        log.debug('Loading static grains from %s', gfn)
        with salt.utils.files.fopen(gfn, 'rb') as fp_:
            try:
                return salt.utils.data.decode(salt.utils.yaml.safe_load(fp_))
            except Exception:
                log.warning("Bad syntax in grains file! Skipping.")
                return {}
    return {}
680080
def _config(name, key=None, **kwargs):
    '''
    
    '''
    if key is None:
        key = name
    if name in kwargs:
        value = kwargs[name]
    else:
        value = __salt__['config.option']('ddns.{0}'.format(key))
        if not value:
            value = None
    return value
453505
def interpret(self, config_dict):
        
        value = config_dict.get(self.name)
        if value is None:
            if self.default is None:
                raise RuntimeError('Missing configuration item: ' + self.name)
            else:
                warnings.warn("Using default {!r} for '{!s}'".format(self.default, self.name),
                              DeprecationWarning)
                if (str != self.value_type) and isinstance(self.default, self.value_type):
                    return self.default
                else:
                    value = self.default

        try:
            if str == self.value_type:
                return str(value)
            if int == self.value_type:
                return int(value)
            if bool == self.value_type:
                if value.lower() == "true":
                    return True
                elif value.lower() == "false":
                    return False
                else:
                    raise RuntimeError(self.name + " must be True or False")
            if float == self.value_type:
                return float(value)
            if list == self.value_type:
                return value.split(" ")
        except Exception:
            raise RuntimeError("Error interpreting config item '{}' with value {!r} and type {}".format(
                self.name, value, self.value_type))

        raise RuntimeError("Unexpected configuration type: " + repr(self.value_type))
123282
def normalize_conf(conf):
    '''
    '''
    conf = conf.copy()
    # check for type error
    check_config(conf)
    # convert some fileds into python suitable format
    from_json_format(conf)
    if 'dmode' not in conf:
        conf['dmode'] = calc_dir_mode(conf['fmode'])
    return conf
232590
def from_json_format(conf):
    ''''''
    if 'fmode' in conf:
        conf['fmode'] = int(conf['fmode'], 8)
    if 'dmode' in conf:
        conf['dmode'] = int(conf['dmode'], 8)