1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 Provides filtered attribute list classes.
19 """
20
21 from suds import *
22 from suds.umx import *
23 from suds.sax import Namespace
24
25
27 """
28 A filtered attribute list.
29 Items are included during iteration if they are in either the (xs) or
30 (xml) namespaces.
31 @ivar raw: The I{raw} attribute list.
32 @type raw: list
33 """
35 """
36 @param attributes: A list of attributes
37 @type attributes: list
38 """
39 self.raw = attributes
40
42 """
43 Get list of I{real} attributes which exclude xs and xml attributes.
44 @return: A list of I{real} attributes.
45 @rtype: I{generator}
46 """
47 for a in self.raw:
48 if self.skip(a): continue
49 yield a
50
52 """
53 Get the number of I{real} attributes which exclude xs and xml attributes.
54 @return: A count of I{real} attributes.
55 @rtype: L{int}
56 """
57 n = 0
58 for a in self.real():
59 n += 1
60 return n
61
63 """
64 Get list of I{filtered} attributes which exclude xs.
65 @return: A list of I{filtered} attributes.
66 @rtype: I{generator}
67 """
68 for a in self.raw:
69 if a.qname() == 'xml:lang':
70 return a.value
71 return None
72
73 - def skip(self, attr):
74 """
75 Get whether to skip (filter-out) the specified attribute.
76 @param attr: An attribute.
77 @type attr: I{Attribute}
78 @return: True if should be skipped.
79 @rtype: bool
80 """
81 ns = attr.namespace()
82 skip = (
83 Namespace.xmlns[1],
84 'http://schemas.xmlsoap.org/soap/encoding/',
85 'http://schemas.xmlsoap.org/soap/envelope/',
86 'http://www.w3.org/2003/05/soap-envelope',
87 )
88 return ( Namespace.xs(ns) or ns[1] in skip )
89