def parse_mr_job_stderr(stderr, counters=None):
 if isinstance(stderr, bytes):
  stderr = BytesIO(stderr)
 if (counters is None):
  counters = {}
 statuses = []
 other = []
 for line in stderr:
  m = _COUNTER_RE.match(line.rstrip('\r\n'))
  if m:
   (group, counter, amount_str) = m.groups()
   group = to_string(group)
   counter = to_string(counter)
   counters.setdefault(group, {})
   counters[group].setdefault(counter, 0)
   counters[group][counter] += int(amount_str)
   continue
  m = _STATUS_RE.match(line.rstrip('\r\n'))
  if m:
   statuses.append(to_string(m.group(1)))
   continue
  other.append(to_string(line))
 return {'counters': counters, 'statuses': statuses, 'other': other}

def parse_mr_job_stderr ( stderr , counters = None ) : if isinstance ( stderr , bytes ) : stderr = BytesIO ( stderr ) if ( counters is None ) : counters = { } statuses = [ ] other = [ ] for line in stderr : m = _COUNTER_RE . match ( line . rstrip ( '\r\n' ) ) if m : ( group , counter , amount_str ) = m . groups ( ) group = to_string ( group ) counter = to_string ( counter ) counters . setdefault ( group , { } ) counters [ group ] . setdefault ( counter , 0 ) counters [ group ] [ counter ] += int ( amount_str ) continue m = _STATUS_RE . match ( line . rstrip ( '\r\n' ) ) if m : statuses . append ( to_string ( m . group ( 1 ) ) ) continue other . append ( to_string ( line ) ) return { 'counters' : counters , 'statuses' : statuses , 'other' : other }
parse counters and status messages out of mrjob output .