def getValue( val, default ): '''Wrapper around gConfig.getValue. Returns typed values''' res = gConfig.getValue( val, default ) if Utils.isiterable( res ): return [ Utils.typedobj_of_string(e) for e in res ] else: return Utils.typedobj_of_string( res )
def getValue(val, default): '''Wrapper around gConfig.getValue. Returns typed values''' res = gConfig.getValue(val, default) if Utils.isiterable(res): return [Utils.typedobj_of_string(e) for e in res] else: return Utils.typedobj_of_string(res)
def getValue(v): """Wrapper around gConfig.getValue. Returns typed values instead of a string value""" res = gConfig.getValue(v) if res.find(",") > -1: # res is a list of values return [Utils.typedobj_of_string(e) for e in List.fromChar(res)] else: return Utils.typedobj_of_string(res)
def typed_dict_of_dict(d): for k in d: if type(d[k]) == dict: d[k] = typed_dict_of_dict(d[k]) else: if d[k].find(",") > -1: d[k] = [Utils.typedobj_of_string(e) for e in List.fromChar(d[k])] else: d[k] = Utils.typedobj_of_string(d[k]) return d
def getTypedDictRootedAt( path ): retval = {} opts = gConfig.getOptionsDict( path ) secs = gConfig.getSections( path ) if not opts[ 'OK' ]: raise CSError, opts[ 'Message' ] if not secs[ 'OK' ]: raise CSError, secs[ 'Message' ] opts = opts[ 'Value' ] secs = secs[ 'Value' ] for k in opts: if opts[ k ].find( "," ) > -1: retval[ k ] = [ Utils.typedobj_of_string(e) for e in List.fromChar(opts[k]) ] else: retval[ k ] = Utils.typedobj_of_string( opts[ k ] ) for i in secs: retval[ i ] = getTypedDictRootedAt( path + "/" + i ) return retval
def getTypedDictRootedAt(path): retval = {} opts = gConfig.getOptionsDict(path) secs = gConfig.getSections(path) if not opts['OK']: raise CSError, opts['Message'] if not secs['OK']: raise CSError, secs['Message'] opts = opts['Value'] secs = secs['Value'] for k in opts: if opts[k].find(",") > -1: retval[k] = [ Utils.typedobj_of_string(e) for e in List.fromChar(opts[k]) ] else: retval[k] = Utils.typedobj_of_string(opts[k]) for i in secs: retval[i] = getTypedDictRootedAt(path + "/" + i) return retval