MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / append_list

Function append_list

flow-rs/src/loader/python/node.rs:209–231  ·  view source on GitHub ↗
(py: Python, value: &toml::Value, list: &PyList)

Source from the content-addressed store, hash-verified

207
208pub fn toml2dict<'a>(py: Python<'a>, args: &toml::value::Table) -> PyResult<&'a PyDict> {
209 fn append_list(py: Python, value: &toml::Value, list: &PyList) -> PyResult<()> {
210 match value {
211 toml::Value::String(s) => list.append(s),
212 toml::Value::Float(f) => list.append(f),
213 toml::Value::Integer(i) => list.append(i),
214 toml::Value::Boolean(b) => list.append(b),
215 toml::Value::Datetime(t) => list.append(t.to_string()),
216 toml::Value::Array(l) => {
217 let pylist = PyList::empty(py);
218 for e in l {
219 append_list(py, e, pylist)?;
220 }
221 list.append(pylist)
222 }
223 toml::Value::Table(d) => {
224 let pydict = PyDict::new(py);
225 for (key, value) in d {
226 fill_dict(py, key, value, pydict)?;
227 }
228 list.append(pydict)
229 }
230 }
231 }
232 fn fill_dict(py: Python, key: &str, value: &toml::Value, dict: &PyDict) -> PyResult<()> {
233 match value {
234 toml::Value::String(s) => dict.set_item(key, s),

Callers 1

fill_dictFunction · 0.85

Calls 2

fill_dictFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected