|
4 | 4 | from xml.etree.ElementTree import Element # nosec B405
|
5 | 5 |
|
6 | 6 | import serializable
|
7 |
| -from serializable import ViewType |
| 7 | +from serializable import ObjectMetadataLibrary, ViewType |
8 | 8 | from serializable.helpers import BaseHelper
|
9 | 9 | from sortedcontainers import SortedSet
|
10 | 10 |
|
|
17 | 17 | from ..schema.schema import SchemaVersion1Dot4, SchemaVersion1Dot5, SchemaVersion1Dot6
|
18 | 18 |
|
19 | 19 |
|
| 20 | + |
20 | 21 | @serializable.serializable_class
|
21 | 22 | class Tool:
|
22 | 23 | """
|
@@ -327,7 +328,24 @@ def xml_normalize(cls, o: ToolsRepository, *,
|
327 | 328 | return elem
|
328 | 329 |
|
329 | 330 | @classmethod
|
330 |
| - def xml_denormalize(cls, o: Element, |
| 331 | + def xml_denormalize(cls, o: Element, *, |
331 | 332 | default_ns: Optional[str],
|
332 |
| - **__: Any) -> ToolsRepository: |
333 |
| - return ToolsRepository() |
| 333 | + prop_info: ObjectMetadataLibrary.SerializableProperty, |
| 334 | + ctx: Type[Any], |
| 335 | + **kwargs: Any) -> ToolsRepository: |
| 336 | + tools: list[Tool] = [] |
| 337 | + components: list[Component] = [] |
| 338 | + services: list[Service] = [] |
| 339 | + |
| 340 | + for e in o: |
| 341 | + tag = e.tag if default_ns is None else e.tag.replace(f'{{{default_ns}}}', '') |
| 342 | + if tag == 'tool': |
| 343 | + tools.append(Tool.from_xml(e)) |
| 344 | + if tag == 'components': |
| 345 | + for c in e: |
| 346 | + components.append(Component.from_xml(c)) |
| 347 | + if tag == 'services': |
| 348 | + for s in e: |
| 349 | + services.append(Service.from_xml(s)) |
| 350 | + |
| 351 | + return ToolsRepository(tools=tools, components=components, services=services) |
0 commit comments