# Path: coherence/extern/et.py
# def new_encode_entity(text, pattern=utf8_escape):
#     def escape_entities(m, map=elementtree.ElementTree._escape_map):
#     def XMLParser(encoding='utf-8'):
# def namespace_map_update(namespaces):
# def indent(elem, level=0):
# def parse_xml(data, encoding="utf-8", dump_invalid_data=False):
# def qname(tag, ns=None):
# def textElement(parent, tag, namespace, text):
# def textElementIfNotNone(parent, tag, namespace, text):
# class ElementInterface(elementtree.ElementTree._ElementInterface): pass


from twisted.python.util import OrderedDict
from coherence.extern.et import ET, textElement
SOAP_ENCODING = "http://schemas.xmlsoap.org/soap/encoding/"

UPNPERRORS = {401: 'Invalid Action',
              402: 'Invalid Args',
              501: 'Action Failed',
              600: 'Argument Value Invalid',
              601: 'Argument Value Out of Range',
              602: 'Optional Action Not Implemented',
              603: 'Out Of Memory',
              604: 'Human Intervention Required',
              605: 'String Argument Too Long',
              606: 'Action Not Authorized',
              607: 'Signature Failure',
              608: 'Signature Missing',
              609: 'Not Encrypted',
              610: 'Invalid Sequence',
              611: 'Invalid Control URL',
              612: 'No Such Session', }


def build_soap_error(status, description='without words'):
    """ builds an UPnP SOAP error msg
    """
    root = ET.Element('s:Fault')
    textElement(root, 'faultcode', None, 's:Client')
    textElement(root, 'faultstring', None, 'UPnPError')
    e = ET.SubElement(root, 'detail')
    e = ET.SubElement(e, 'UPnPError')
    e.attrib['xmlns'] = 'urn:schemas-upnp-org:control-1-0'
    textElement(e, 'errorCode', None, str(status))

# Path: coherence/extern/et.py
# def new_encode_entity(text, pattern=utf8_escape):
#     def escape_entities(m, map=elementtree.ElementTree._escape_map):
#     def XMLParser(encoding='utf-8'):
# def namespace_map_update(namespaces):
# def indent(elem, level=0):
# def parse_xml(data, encoding="utf-8", dump_invalid_data=False):
# def qname(tag, ns=None):
# def textElement(parent, tag, namespace, text):
# def textElementIfNotNone(parent, tag, namespace, text):
# class ElementInterface(elementtree.ElementTree._ElementInterface): pass


# Path: coherence/upnp/core/soap_lite.py
from twisted.python.util import OrderedDict
from coherence.extern.et import ET, textElement

SOAP_ENCODING = "http://schemas.xmlsoap.org/soap/encoding/"

UPNPERRORS = {401: 'Invalid Action',
              402: 'Invalid Args',
              501: 'Action Failed',
              600: 'Argument Value Invalid',
              601: 'Argument Value Out of Range',
              602: 'Optional Action Not Implemented',
              603: 'Out Of Memory',
              604: 'Human Intervention Required',
              605: 'String Argument Too Long',
              606: 'Action Not Authorized',
              607: 'Signature Failure',
              608: 'Signature Missing',
              609: 'Not Encrypted',
              610: 'Invalid Sequence',
              611: 'Invalid Control URL',
              612: 'No Such Session', }


def build_soap_error(status, description='without words'):
    """ builds an UPnP SOAP error msg
    """
    root = ET.Element('s:Fault')
    textElement(root, 'faultcode', None, 's:Client')
    textElement(root, 'faultstring', None, 'UPnPError')
    e = ET.SubElement(root, 'detail')
    e = ET.SubElement(e, 'UPnPError')
    e.attrib['xmlns'] = 'urn:schemas-upnp-org:control-1-0'
    textElement(e, 'errorCode', None, str(status))

    textElement(e, 'errorDescription', None, UPNPERRORS.get(status, description))