def toResponse(stanza, stanzaType=None):
 toAddr = stanza.getAttribute('from')
 fromAddr = stanza.getAttribute('to')
 stanzaID = stanza.getAttribute('id')
 response = domish.Element((None, stanza.name))
 if toAddr:
  response['to'] = toAddr
 if fromAddr:
  response['from'] = fromAddr
 if stanzaID:
  response['id'] = stanzaID
 if stanzaType:
  response['type'] = stanzaType
 return response

def toResponse ( stanza , stanzaType = None ) : toAddr = stanza . getAttribute ( 'from' ) fromAddr = stanza . getAttribute ( 'to' ) stanzaID = stanza . getAttribute ( 'id' ) response = domish . Element ( ( None , stanza . name ) ) if toAddr : response [ 'to' ] = toAddr if fromAddr : response [ 'from' ] = fromAddr if stanzaID : response [ 'id' ] = stanzaID if stanzaType : response [ 'type' ] = stanzaType return response
create a response stanza from another stanza .