Example #1
0
File: CS.py Project: bmb/DIRAC
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 )
Example #2
0
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)
Example #3
0
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)
Example #4
0
 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
Example #5
0
File: CS.py Project: bmb/DIRAC
  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
Example #6
0
    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