def get_content_view(viewmode, hdrItems, content, limit, logfunc):
 if (not content):
  return ('No content', '')
 msg = []
 hdrs = flow.ODictCaseless([list(i) for i in hdrItems])
 enc = hdrs.get_first('content-encoding')
 if (enc and (enc != 'identity')):
  decoded = encoding.decode(enc, content)
  if decoded:
   content = decoded
   msg.append(('[decoded %s]' % enc))
 try:
  ret = viewmode(hdrs, content, limit)
 except Exception as e:
  s = traceback.format_exc()
  s = ('Content viewer failed: \n' + s)
  logfunc(s)
  ret = None
 if (not ret):
  ret = get('Raw')(hdrs, content, limit)
  msg.append("Couldn't parse: falling back to Raw")
 else:
  msg.append(ret[0])
 return (' '.join(msg), ret[1])

def get_content_view ( viewmode , hdrItems , content , limit , logfunc ) : if ( not content ) : return ( 'No content' , '' ) msg = [ ] hdrs = flow . ODictCaseless ( [ list ( i ) for i in hdrItems ] ) enc = hdrs . get_first ( 'content-encoding' ) if ( enc and ( enc != 'identity' ) ) : decoded = encoding . decode ( enc , content ) if decoded : content = decoded msg . append ( ( '[decoded %s]' % enc ) ) try : ret = viewmode ( hdrs , content , limit ) except Exception as e : s = traceback . format_exc ( ) s = ( 'Content viewer failed: \n' + s ) logfunc ( s ) ret = None if ( not ret ) : ret = get ( 'Raw' ) ( hdrs , content , limit ) msg . append ( "Couldn't parse: falling back to Raw" ) else : msg . append ( ret [ 0 ] ) return ( ' ' . join ( msg ) , ret [ 1 ] )
returns a tuple .