MCPcopy Create free account
hub / github.com/astra-toolbox/astra-toolbox / XMLNode2dict

Function XMLNode2dict

python/astra/src/PythonPluginAlgorithm.cpp:175–206  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175PyObject* XMLNode2dict(XMLNode node){
176 PyObject *dct = PyDict_New();
177 PyObject *opts = PyDict_New();
178 if(node.hasAttribute("type")){
179 PyObject *obj = pyStringFromString(node.getAttribute("type").c_str());
180 PyDict_SetItemString(dct, "type", obj);
181 Py_DECREF(obj);
182 }
183 std::list<XMLNode> nodes = node.getNodes();
184 std::list<XMLNode>::iterator it = nodes.begin();
185 while(it!=nodes.end()){
186 XMLNode subnode = *it;
187 if(subnode.getName()=="Option"){
188 PyObject *obj;
189 if(subnode.hasAttribute("value")){
190 obj = stringToPythonValue(subnode.getAttribute("value"));
191 }else{
192 obj = stringToPythonValue(subnode.getContent());
193 }
194 PyDict_SetItemString(opts, subnode.getAttribute("key").c_str(), obj);
195 Py_DECREF(obj);
196 }else{
197 PyObject *obj = stringToPythonValue(subnode.getContent());
198 PyDict_SetItemString(dct, subnode.getName().c_str(), obj);
199 Py_DECREF(obj);
200 }
201 ++it;
202 }
203 PyDict_SetItemString(dct, "options", opts);
204 Py_DECREF(opts);
205 return dct;
206}
207
208
209}

Callers 1

initializeMethod · 0.85

Calls 7

pyStringFromStringFunction · 0.85
stringToPythonValueFunction · 0.85
hasAttributeMethod · 0.80
getAttributeMethod · 0.80
getNodesMethod · 0.80
getNameMethod · 0.80
getContentMethod · 0.80

Tested by

no test coverage detected