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

Function fill_dict

flow-rs/src/loader/python/node.rs:232–254  ·  view source on GitHub ↗
(py: Python, key: &str, value: &toml::Value, dict: &PyDict)

Source from the content-addressed store, hash-verified

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),
235 toml::Value::Float(f) => dict.set_item(key, f),
236 toml::Value::Integer(i) => dict.set_item(key, i),
237 toml::Value::Boolean(b) => dict.set_item(key, b),
238 toml::Value::Datetime(t) => dict.set_item(key, t.to_string()),
239 toml::Value::Array(l) => {
240 let pylist = PyList::empty(py);
241 for e in l {
242 append_list(py, e, pylist)?;
243 }
244 dict.set_item(key, pylist)
245 }
246 toml::Value::Table(d) => {
247 let pydict = PyDict::new(py);
248 for (key, value) in d {
249 fill_dict(py, key, value, pydict)?;
250 }
251 dict.set_item(key, pydict)
252 }
253 }
254 }
255 let dict = PyDict::new(py);
256 for (key, value) in args {
257 fill_dict(py, key, value, dict)?;

Callers 2

append_listFunction · 0.85
toml2dictFunction · 0.85

Calls 1

append_listFunction · 0.85

Tested by

no test coverage detected