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

Class SchemaCollection

suds/xsd/schema.py:39–158  ·  view source on GitHub ↗

A collection of schema objects. This class is needed because WSDLs may contain more then one node. @ivar wsdl: A wsdl object. @type wsdl: L{suds.wsdl.Definitions} @ivar children: A list contained schemas. @type children: [L{Schema},...] @ivar namespaces: A dic

Source from the content-addressed store, hash-verified

37
38
39class SchemaCollection:
40 """
41 A collection of schema objects. This class is needed because WSDLs
42 may contain more then one <schema/> node.
43 @ivar wsdl: A wsdl object.
44 @type wsdl: L{suds.wsdl.Definitions}
45 @ivar children: A list contained schemas.
46 @type children: [L{Schema},...]
47 @ivar namespaces: A dictionary of contained schemas by namespace.
48 @type namespaces: {str:L{Schema}}
49 """
50
51 def __init__(self, wsdl):
52 """
53 @param wsdl: A wsdl object.
54 @type wsdl: L{suds.wsdl.Definitions}
55 """
56 self.wsdl = wsdl
57 self.children = []
58 self.namespaces = {}
59
60 def add(self, schema):
61 """
62 Add a schema node to the collection. Schema(s) within the same target
63 namespace are consolidated.
64 @param schema: A schema object.
65 @type schema: (L{Schema})
66 """
67 key = schema.tns[1]
68 existing = self.namespaces.get(key)
69 if existing is None:
70 self.children.append(schema)
71 self.namespaces[key] = schema
72 else:
73 existing.root.children += schema.root.children
74 existing.root.nsprefixes.update(schema.root.nsprefixes)
75
76 def load(self, options):
77 """
78 Load the schema objects for the root nodes.
79 - de-references schemas
80 - merge schemas
81 @param options: An options dictionary.
82 @type options: L{options.Options}
83 @return: The merged schema.
84 @rtype: L{Schema}
85 """
86 if options.autoblend:
87 self.autoblend()
88 for child in self.children:
89 child.build()
90 for child in self.children:
91 child.open_imports(options)
92 for child in self.children:
93 child.dereference()
94 log.debug('loaded:\n%s', self)
95 merged = self.merge()
96 log.debug('MERGED:\n%s', merged)

Callers 1

build_schemaMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected