loam/tools.py
def set_conf_str(conf, optstrs):
    """Set options from a list of section.option=value string.

    Args:
        conf (:class:`~loam.manager.ConfigurationManager`): the conf to update.
        optstrs (list of str): the list of 'section.option=value' formatted
            string.
    """
    falsy = ['0', 'no', 'n', 'off', 'false', 'f']
    bool_actions = ['store_true', 'store_false', internal.Switch]
    for optstr in optstrs:
        opt, val = optstr.split('=', 1)
        sec, opt = opt.split('.', 1)
        if sec not in conf:
            raise error.SectionError(sec)
        if opt not in conf[sec]:
            raise error.OptionError(opt)
        meta = conf[sec].def_[opt]
        if meta.default is None:
            if 'type' in meta.cmd_kwargs:
                cast = meta.cmd_kwargs['type']
            else:
                act = meta.cmd_kwargs.get('action')
                cast = bool if act in bool_actions else str
        else:
            cast = type(meta.default)
        if cast is bool and val.lower() in falsy:
            val = ''
        conf[sec][opt] = cast(val)
def set_conf_str(conf, optstrs):
    falsy = ['0', 'no', 'n', 'off', 'false', 'f']
    bool_actions = ['store_true', 'store_false', internal.Switch]
    for optstr in optstrs:
        opt, val = optstr.split('=', 1)
        sec, opt = opt.split('.', 1)
        if sec not in conf:
            raise error.SectionError(sec)
        if opt not in conf[sec]:
            raise error.OptionError(opt)
        meta = conf[sec].def_[opt]
        if meta.default is None:
            if 'type' in meta.cmd_kwargs:
                cast = meta.cmd_kwargs['type']
            else:
                act = meta.cmd_kwargs.get('action')
                cast = bool if act in bool_actions else str
        else:
            cast = type(meta.default)
        if cast is bool and val.lower() in falsy:
            val = ''
        conf[sec][opt] = cast(val)
def set_conf_str ( conf , optstrs ) : falsy = [ '0' , 'no' , 'n' , 'off' , 'false' , 'f' ] bool_actions = [ 'store_true' , 'store_false' , internal . Switch ] for optstr in optstrs : opt , val = optstr . split ( '=' , 1 ) sec , opt = opt . split ( '.' , 1 ) if sec not in conf : raise error . SectionError ( sec ) if opt not in conf [ sec ] : raise error . OptionError ( opt ) meta = conf [ sec ] . def_ [ opt ] if meta . default is None : if 'type' in meta . cmd_kwargs : cast = meta . cmd_kwargs [ 'type' ] else : act = meta . cmd_kwargs . get ( 'action' ) cast = bool if act in bool_actions else str else : cast = type ( meta . default ) if cast is bool and val . lower ( ) in falsy : val = '' conf [ sec ] [ opt ] = cast ( val )
Set options from a list of section.option=value string.

    Args:
        conf (:class:`~loam.manager.ConfigurationManager`): the conf to update.
        optstrs (list of str): the list of 'section.option=value' formatted
            string.
Set options from a list of section . option = value string .