def extract_messages(doctree):
 for node in doctree.traverse(is_translatable):
  if isinstance(node, addnodes.translatable):
   for msg in node.extract_original_messages():
    (yield (node, msg))
   continue
  if isinstance(node, LITERAL_TYPE_NODES):
   msg = node.rawsource
   if (not msg):
    msg = node.astext()
  elif isinstance(node, IMAGE_TYPE_NODES):
   msg = ('.. image:: %s' % node['uri'])
   if node.get('alt'):
    msg += ('\n   :alt: %s' % node['alt'])
  elif isinstance(node, META_TYPE_NODES):
   msg = node.rawcontent
  elif is_pending_meta(node):
   msg = node.details['nodes'][0].rawcontent
  else:
   msg = node.rawsource.replace('\n', ' ').strip()
  if msg:
   (yield (node, msg))

def extract_messages ( doctree ) : for node in doctree . traverse ( is_translatable ) : if isinstance ( node , addnodes . translatable ) : for msg in node . extract_original_messages ( ) : ( yield ( node , msg ) ) continue if isinstance ( node , LITERAL_TYPE_NODES ) : msg = node . rawsource if ( not msg ) : msg = node . astext ( ) elif isinstance ( node , IMAGE_TYPE_NODES ) : msg = ( '.. image:: %s' % node [ 'uri' ] ) if node . get ( 'alt' ) : msg += ( '\n   :alt: %s' % node [ 'alt' ] ) elif isinstance ( node , META_TYPE_NODES ) : msg = node . rawcontent elif is_pending_meta ( node ) : msg = node . details [ 'nodes' ] [ 0 ] . rawcontent else : msg = node . rawsource . replace ( '\n' , ' ' ) . strip ( ) if msg : ( yield ( node , msg ) )
extract "messages" from a list of exceptions or other objects .