/usr/lib/python2.7/dist-packages/zeep/wsa.py is in python-zeep 2.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | import uuid
from lxml import etree
from lxml.builder import ElementMaker
from zeep import ns
from zeep.plugins import Plugin
from zeep.wsdl.utils import get_or_create_header
WSA = ElementMaker(namespace=ns.WSA, nsmap={'wsa': ns.WSA})
class WsAddressingPlugin(Plugin):
nsmap = {
'wsa': ns.WSA
}
def egress(self, envelope, http_headers, operation, binding_options):
"""Apply the ws-addressing headers to the given envelope."""
wsa_action = operation.input.abstract.wsa_action
if not wsa_action:
wsa_action = operation.soapaction
header = get_or_create_header(envelope)
headers = [
WSA.Action(wsa_action),
WSA.MessageID('urn:uuid:' + str(uuid.uuid4())),
WSA.To(binding_options['address']),
]
header.extend(headers)
# the top_nsmap kwarg was added in lxml 3.5.0
if etree.LXML_VERSION[:2] >= (3, 5):
etree.cleanup_namespaces(
header,
keep_ns_prefixes=header.nsmap,
top_nsmap=self.nsmap)
else:
etree.cleanup_namespaces(header)
return envelope, http_headers
|