def textFromEventDict(eventDict):
 edm = eventDict['message']
 if (not edm):
  if (eventDict['isError'] and ('failure' in eventDict)):
   why = eventDict.get('why')
   if why:
    why = reflect.safe_str(why)
   else:
    why = 'Unhandled Error'
   try:
    traceback = eventDict['failure'].getTraceback()
   except Exception as e:
    traceback = ('(unable to obtain traceback): ' + str(e))
   text = ((why + '\n') + traceback)
  elif ('format' in eventDict):
   text = _safeFormat(eventDict['format'], eventDict)
  else:
   return None
 else:
  text = ' '.join(map(reflect.safe_str, edm))
 return text

def textFromEventDict ( eventDict ) : edm = eventDict [ 'message' ] if ( not edm ) : if ( eventDict [ 'isError' ] and ( 'failure' in eventDict ) ) : why = eventDict . get ( 'why' ) if why : why = reflect . safe_str ( why ) else : why = 'Unhandled Error' try : traceback = eventDict [ 'failure' ] . getTraceback ( ) except Exception as e : traceback = ( '(unable to obtain traceback): ' + str ( e ) ) text = ( ( why + '\n' ) + traceback ) elif ( 'format' in eventDict ) : text = _safeFormat ( eventDict [ 'format' ] , eventDict ) else : return None else : text = ' ' . join ( map ( reflect . safe_str , edm ) ) return text
extract text from an event dict passed to a log observer .