def _coerceLevel()

in scripts/yapl/Trace.py [0:0]


  def _coerceLevel(self,level):
    """
      Return an integer representation from the Level class for the given
      string representation of a trace level.
       
      The traceLevels hash table is used to do the translation.    
       
      The incoming level is intended to be a Jython string.  If it is not 
      a string then it is returned as is.
    """
    result = level
    if (type(level) == type("") or type(level) == type(u"")):
      level = level.lower()
      result = Trace.traceLevels.get(level)
      # Need an explicit test for None in the following if condition because
      # trace levels "none" and "off" map to a level with a value of 0
      if (result == None):
        raise TraceLevelException("Unknown trace level: %s  Valid trace levels: %s" % (level,Trace.traceNames))
      #endIf
    #endIf
    return result