# Path: pyxmpp2/utils.py
# def xml_elements_equal(element1, element2, ignore_level1_cdata = False):
# def datetime_utc_to_local(utc):
# def datetime_local_to_utc(local):
# _MINUTE = datetime.timedelta(minutes = 1)
# _NULLDELTA = datetime.timedelta()
# 
# Path: pyxmpp2/exceptions.py
# class BadRequestProtocolError(ProtocolError):
#     """Raised when invalid stanza is processed and 'bad-request' error should
#     be reported."""
#     def __init__(self, message):
#         ProtocolError.__init__(self, "bad-request", message)
# 
# class JIDMalformedProtocolError(ProtocolError, JIDError):
#     """Raised when invalid JID is encountered."""
#     def __init__(self, message):
#         JIDError.__init__(self)
#         ProtocolError.__init__(self, "jid-malformed", message)
# 
# class JIDError(Error, ValueError):
#     "Exception raised when invalid JID is used"
#     pass


import base64
import binascii
import libxml2
import re
import pyxmpp.jid
from ..utils import to_utf8,from_utf8
from ..xmlextra import get_node_ns
from ..objects import StanzaPayloadObject
from ..exceptions import BadRequestProtocolError, JIDMalformedProtocolError, JIDError
        elif "dom" in self.type and "intl" in self.type:
            raise ValueError("Both 'dom' and 'intl' specified in vcard ADR")

    def rfc2426(self):
        """RFC2426-encode the field content.

        :return: the field in the RFC 2426 format.
        :returntype: `str`"""
        return rfc2425encode("adr",u';'.join(quote_semicolon(val) for val in
                (self.pobox,self.extadr,self.street,self.locality,
                        self.region,self.pcode,self.ctry)),
                {"type":",".join(self.type)})

    def as_xml(self,parent):
        """Create vcard-tmp XML representation of the field.

        :Parameters:
            - `parent`: parent node for the element
        :Types:
            - `parent`: `libxml2.xmlNode`

        :return: xml node with the field data.
        :returntype: `libxml2.xmlNode`"""
        n=parent.newChild(None,"ADR",None)
        for t in ("home","work","postal","parcel","dom","intl","pref"):
            if t in self.type:
                n.newChild(None,t.upper(),None)
        n.newTextChild(None,"POBOX",to_utf8(self.pobox))
        n.newTextChild(None,"EXTADD",to_utf8(self.extadr))
        n.newTextChild(None,"STREET",to_utf8(self.street))

# Path: pyxmpp2/utils.py
# def xml_elements_equal(element1, element2, ignore_level1_cdata = False):
# def datetime_utc_to_local(utc):
# def datetime_local_to_utc(local):
# _MINUTE = datetime.timedelta(minutes = 1)
# _NULLDELTA = datetime.timedelta()
# 
# Path: pyxmpp2/exceptions.py
# class BadRequestProtocolError(ProtocolError):
#     """Raised when invalid stanza is processed and 'bad-request' error should
#     be reported."""
#     def __init__(self, message):
#         ProtocolError.__init__(self, "bad-request", message)
# 
# class JIDMalformedProtocolError(ProtocolError, JIDError):
#     """Raised when invalid JID is encountered."""
#     def __init__(self, message):
#         JIDError.__init__(self)
#         ProtocolError.__init__(self, "jid-malformed", message)
# 
# class JIDError(Error, ValueError):
#     "Exception raised when invalid JID is used"
#     pass


# Path: pyxmpp2/ext/vcard.py
import base64
import binascii
import libxml2
import re
import pyxmpp.jid
from ..utils import to_utf8,from_utf8
from ..xmlextra import get_node_ns
from ..objects import StanzaPayloadObject
from ..exceptions import BadRequestProtocolError, JIDMalformedProtocolError, JIDError

        elif "dom" in self.type and "intl" in self.type:
            raise ValueError("Both 'dom' and 'intl' specified in vcard ADR")

    def rfc2426(self):
        """RFC2426-encode the field content.

        :return: the field in the RFC 2426 format.
        :returntype: `str`"""
        return rfc2425encode("adr",u';'.join(quote_semicolon(val) for val in
                (self.pobox,self.extadr,self.street,self.locality,
                        self.region,self.pcode,self.ctry)),
                {"type":",".join(self.type)})

    def as_xml(self,parent):
        """Create vcard-tmp XML representation of the field.

        :Parameters:
            - `parent`: parent node for the element
        :Types:
            - `parent`: `libxml2.xmlNode`

        :return: xml node with the field data.
        :returntype: `libxml2.xmlNode`"""
        n=parent.newChild(None,"ADR",None)
        for t in ("home","work","postal","parcel","dom","intl","pref"):
            if t in self.type:
                n.newChild(None,t.upper(),None)
        n.newTextChild(None,"POBOX",to_utf8(self.pobox))
        n.newTextChild(None,"EXTADD",to_utf8(self.extadr))
        n.newTextChild(None,"STREET",to_utf8(self.street))

        n.newTextChild(None,"LOCALITY",to_utf8(self.locality))