MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / PathResolver

Class PathResolver

suds/resolver.py:70–221  ·  view source on GitHub ↗

Resolveds the definition object for the schema type located at the specified path. The path may contain (.) dot notation to specify nested types. @ivar wsdl: A wsdl object. @type wsdl: L{wsdl.Definitions}

Source from the content-addressed store, hash-verified

68
69
70class PathResolver(Resolver):
71 """
72 Resolveds the definition object for the schema type located at the
73 specified path.
74 The path may contain (.) dot notation to specify nested types.
75 @ivar wsdl: A wsdl object.
76 @type wsdl: L{wsdl.Definitions}
77 """
78
79 def __init__(self, wsdl, ps='.'):
80 """
81 @param wsdl: A schema object.
82 @type wsdl: L{wsdl.Definitions}
83 @param ps: The path separator character
84 @type ps: char
85 """
86 Resolver.__init__(self, wsdl.schema)
87 self.wsdl = wsdl
88 self.altp = re.compile('({)(.+)(})(.+)')
89 self.splitp = re.compile(r'({.+})*[^\%s]+' % ps[0])
90
91 def find(self, path, resolved=True):
92 """
93 Get the definition object for the schema type located at the specified
94 path.
95 The path may contain (.) dot notation to specify nested types.
96 Actually, the path separator is usually a (.) but can be redefined
97 during contruction.
98 @param path: A (.) separated path to a schema type.
99 @type path: basestring
100 @param resolved: A flag indicating that the fully resolved type
101 should be returned.
102 @type resolved: boolean
103 @return: The found schema I{type}
104 @rtype: L{xsd.sxbase.SchemaObject}
105 """
106 result = None
107 parts = self.split(path)
108 try:
109 result = self.root(parts)
110 if len(parts) > 1:
111 result = result.resolve(nobuiltin=True)
112 result = self.branch(result, parts)
113 result = self.leaf(result, parts)
114 if resolved:
115 result = result.resolve(nobuiltin=True)
116 except PathResolver.BadPath:
117 log.error('path: "%s", not-found' % path)
118 return result
119
120 def root(self, parts):
121 """
122 Find the path root.
123 @param parts: A list of path parts.
124 @type parts: [str,..]
125 @return: The root.
126 @rtype: L{xsd.sxbase.SchemaObject}
127 """

Callers 2

__init__Method · 0.90
separatorMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected