7
7
import os
8
8
import math
9
9
import numpy as np
10
- import xmltodict
10
+
11
11
12
12
from modelspec .base_types import print_
13
13
from modelspec .base_types import EvaluableExpression
@@ -78,7 +78,7 @@ def load_xml(filename: str):
78
78
79
79
def element_to_dict (element ):
80
80
"""
81
- Convert an ElementTree element to a dictionary.
81
+ This convert an ElementTree element to a dictionary.
82
82
83
83
Args:
84
84
element: The ElementTree element to convert.
@@ -103,6 +103,15 @@ def element_to_dict(element):
103
103
104
104
105
105
def convert_values (value ):
106
+ """
107
+ This recursively converts values to their actual types.
108
+
109
+ Args:
110
+ value: The value to be converted.
111
+
112
+ Returns:
113
+ The converted value with its actual data type.
114
+ """
106
115
if isinstance (value , str ):
107
116
if value .isdigit ():
108
117
return int (value )
@@ -143,7 +152,7 @@ def save_to_yaml_file(info_dict, filename, indent=4):
143
152
144
153
def save_to_xml_file (info_dict , filename , indent = 4 , root = "modelspec" ):
145
154
"""
146
- Save a dictionary to an XML file.
155
+ This saves a dictionary to an XML file.
147
156
148
157
Args:
149
158
info_dict (dict): The dictionary containing the data to be saved.
@@ -171,6 +180,16 @@ def save_to_xml_file(info_dict, filename, indent=4, root="modelspec"):
171
180
172
181
173
182
def build_xml_element (parent , data ):
183
+ """
184
+ This recursively builds an XML element structure from a dictionary or a list.
185
+
186
+ Args:
187
+ parent: The parent XML element to attach the new element(s) to.
188
+ data: The data to convert into XML elements.
189
+
190
+ Returns:
191
+ None
192
+ """
174
193
if isinstance (data , dict ):
175
194
for key , value in data .items ():
176
195
if isinstance (value , dict ):
0 commit comments