dirtyebay/utils.py
def _default_ns_prefix(nsmap):
    """
    XML doc may have several prefix:namespace_url pairs, can also specify
    a namespace_url as default, tags in that namespace don't need a prefix
    NOTE:
    we rely on default namespace also present in prefixed form, I'm not sure if
    this is an XML certainty or a quirk of the eBay WSDLs

    in our case the WSDL contains:
        <wsdl:documentation>
            <Version>1.0.0</Version>
        </wsdl:documentation>
    ...but our query needs to give a prefix to the path of `Version` so we need
    to determine the default namespace of the doc, find the matching prefix and
    return it
    """
    if None in nsmap:
        default_url = nsmap[None]
        prefix = None
        for key, val in nsmap.iteritems():
            if val == default_url and key is not None:
                prefix = key
                break
        else:
            raise ValueError(
                "Default namespace {url} not found as a prefix".format(
                    url=default_url
                )
            )
        return prefix
    raise ValueError("No default namespace found in map")
def _default_ns_prefix(nsmap):
    """
    XML doc may have several prefix:namespace_url pairs, can also specify
    a namespace_url as default, tags in that namespace don't need a prefix
    NOTE:
    we rely on default namespace also present in prefixed form, I'm not sure if
    this is an XML certainty or a quirk of the eBay WSDLs

    in our case the WSDL contains:
        <wsdl:documentation>
            <Version>1.0.0</Version>
        </wsdl:documentation>
    ...but our query needs to give a prefix to the path of `Version` so we need
    to determine the default namespace of the doc, find the matching prefix and
    return it
    """
    if None in nsmap:
        default_url = nsmap[None]
        prefix = None
        for key, val in nsmap.iteritems():
            if val == default_url and key is not None:
                prefix = key
                break
        else:
            raise ValueError(
                "Default namespace {url} not found as a prefix".format(
                    url=default_url
                )
            )
        return prefix
    raise ValueError("No default namespace found in map")
XML doc may have several prefix:namespace_url pairs, can also specify
    a namespace_url as default, tags in that namespace don't need a prefix
    NOTE:
    we rely on default namespace also present in prefixed form, I'm not sure if
    this is an XML certainty or a quirk of the eBay WSDLs

    in our case the WSDL contains:
        <wsdl:documentation>
            <Version>1.0.0</Version>
        </wsdl:documentation>
    ...but our query needs to give a prefix to the path of `Version` so we need
    to determine the default namespace of the doc, find the matching prefix and
    return it