xoa.cfgm.get_spec

xoa.cfgm.get_spec(spec, validator=None)[source]

Get an option specification

Parameters:
  • spec – the specification string

  • validator – (optional) the validator to use

Returns:

dict – A dict with keys:

funcname:

the validation type name

type:

same as funcname

args:

the positionnal arguments

kwargs:

the named arguments

default:

the default value

iterable:

if the value is list-like

func:

the validation function

argtype:

the function used with argparse

Read access to these keys can also be done as attribute of the returned dict (d.funcname == d['funcname'], …)

For example, a specification file containing:

[section]
    option = integer(default=0, min=-10, max=10)

Would return:

{'funcname': integer, 'args': [],
'kwargs': {'min': '-10', 'max': '10'}, 'default:' 0,
'opttype': 'int', 'argtype': int,
'func':is_integer, 'iterable': None}

This can be usefull when you added extraneous named arguments into your specification file for your own use.