/usr/lib/python2.7/dist-packages/zeep/utils.py is in python-zeep 0.23.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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | import inspect
from lxml import etree
class _NotSetClass(object):
def __repr__(self):
return 'NotSet'
NotSet = _NotSetClass()
def qname_attr(node, attr_name, target_namespace=None):
value = node.get(attr_name)
if value is not None:
return as_qname(value, node.nsmap, target_namespace)
def as_qname(value, nsmap, target_namespace):
"""Convert the given value to a QName"""
if ':' in value:
prefix, local = value.split(':')
namespace = nsmap.get(prefix, prefix)
return etree.QName(namespace, local)
if target_namespace:
return etree.QName(target_namespace, value)
if nsmap.get(None):
return etree.QName(nsmap[None], value)
return etree.QName(value)
def findall_multiple_ns(node, name, namespace_sets):
result = []
for nsmap in namespace_sets:
result.extend(node.findall(name, namespaces=nsmap))
return result
def get_version():
from zeep import __version__ # cyclic import
return __version__
def get_base_class(objects):
"""Return the best base class for multiple objects.
Implementation is quick and dirty, might be done better.. ;-)
"""
bases = [inspect.getmro(obj.__class__)[::-1] for obj in objects]
num_objects = len(objects)
max_mro = max(len(mro) for mro in bases)
base_class = None
for i in range(max_mro):
try:
if len({bases[j][i] for j in range(num_objects)}) > 1:
break
except IndexError:
break
base_class = bases[0][i]
return base_class
|