def read_valuation(s, encoding=None):
 if (encoding is not None):
  s = s.decode(encoding)
 statements = []
 for (linenum, line) in enumerate(s.splitlines()):
  line = line.strip()
  if (line.startswith(u'#') or (line == u'')):
   continue
  try:
   statements.append(_read_valuation_line(line))
  except ValueError:
   raise ValueError((u'Unable to parse line %s: %s' % (linenum, line)))
 return Valuation(statements)

def read_valuation ( s , encoding = None ) : if ( encoding is not None ) : s = s . decode ( encoding ) statements = [ ] for ( linenum , line ) in enumerate ( s . splitlines ( ) ) : line = line . strip ( ) if ( line . startswith ( u'#' ) or ( line == u'' ) ) : continue try : statements . append ( _read_valuation_line ( line ) ) except ValueError : raise ValueError ( ( u'Unable to parse line %s: %s' % ( linenum , line ) ) ) return Valuation ( statements )
convert a valuation string into a valuation .