def parseTraceString()

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


def parseTraceString(traceString):
  """
    Return a list of TraceSpecification instances that represent a parsing of the given trace string.
    The returned list holds a TraceSpecifification instance for each trace specification in the given 
    trace string.
  """
  result = []
  # If the given traceString is enclosed in double-quotes,
  # then strip the double-quotes.
  if (traceString[0] == '"' and traceString[-1] == '"'):
    traceString = traceString[1:-1]
  #endIf
  traceStrings = traceString.split(":")
  for trace in traceStrings:
    traceParts = trace.split("=")
    if (len(traceParts) != 2):
      raise TraceSpecificationException("Encountered an invalid trace string: %s  A trace string looks like <module_pattern>=<level>." % trace)
    #endIf
    
    modulePattern = traceParts[0]
    level = traceParts[1]
    result.append(TraceSpecification(modulePattern,level))
  #endFor
  return result