dirtyebay/utils.py
def version_from_wsdl(wsdl_tree):
    """
    returns: API version number <str>
    raises: <VersionNotFound>

    NOTE:
    relies on presence of documentation node in the WSDLs:
        <wsdl:documentation>
            <Version>1.0.0</Version>
        </wsdl:documentation>
    """
    prefix = _default_ns_prefix(wsdl_tree.nsmap)

    # XPath doesn't allow empty prefix:
    safe_map = wsdl_tree.nsmap.copy()
    try:
        del safe_map[None]
    except KeyError:
        pass

    try:
        # various eBay WSDLs are inconsistent - need case-insensitive matching
        version_el = wsdl_tree.xpath(
            'wsdl:service/wsdl:documentation/'
            '*[self::{p}:version or self::{p}:Version]'.format(p=prefix),
            namespaces=safe_map
        )[0]
    except IndexError:
        raise VersionNotFound(
            'Version not found in WSDL service documentation'
        )
    else:
        return version_el.text
def version_from_wsdl(wsdl_tree):
    """
    returns: API version number <str>
    raises: <VersionNotFound>

    NOTE:
    relies on presence of documentation node in the WSDLs:
        <wsdl:documentation>
            <Version>1.0.0</Version>
        </wsdl:documentation>
    """
    prefix = _default_ns_prefix(wsdl_tree.nsmap)

    # XPath doesn't allow empty prefix:
    safe_map = wsdl_tree.nsmap.copy()
    try:
        del safe_map[None]
    except KeyError:
        pass

    try:
        # various eBay WSDLs are inconsistent - need case-insensitive matching
        version_el = wsdl_tree.xpath(
            'wsdl:service/wsdl:documentation/'
            '*[self::{p}:version or self::{p}:Version]'.format(p=prefix),
            namespaces=safe_map
        )[0]
    except IndexError:
        raise VersionNotFound(
            'Version not found in WSDL service documentation'
        )
    else:
        return version_el.text
returns: API version number <str>
    raises: <VersionNotFound>

    NOTE:
    relies on presence of documentation node in the WSDLs:
        <wsdl:documentation>
            <Version>1.0.0</Version>
        </wsdl:documentation>