'Prepare the stanza for sending a reply.
Swaps the ``\'from\'`` and ``\'to\'`` attributes.
If ``clear=True``, then also remove the stanza\'s
contents to make room for the reply content.
For client streams, the ``\'from\'`` attribute is removed.
:param bool clear: Indicates if the stanza\'s contents should be
removed. Defaults to ``True``.'

def reply(self, clear=True):

    if (self.stream and hasattr(self.stream, u'is_component') and self.stream.is_component):
        (self[u'from'], self[u'to']) = (self[u'to'], self[u'from'])
    else:
        self[u'to'] = self[u'from']
        del self[u'from']
    if clear:
        self.clear()
    return self
