(
spec: &PyObjectRef,
key: &str,
vm: &VirtualMachine,
)
| 220 | } |
| 221 | |
| 222 | fn get_dict_opt_u64( |
| 223 | spec: &PyObjectRef, |
| 224 | key: &str, |
| 225 | vm: &VirtualMachine, |
| 226 | ) -> PyResult<Option<u64>> { |
| 227 | let dict = spec.downcast_ref::<PyDict>().ok_or_else(|| { |
| 228 | vm.new_type_error("Filter specifier must be a dict or dict-like object") |
| 229 | })?; |
| 230 | match dict.get_item_opt(key, vm)? { |
| 231 | Some(obj) => Ok(Some(obj.try_into_value::<u64>(vm)?)), |
| 232 | None => Ok(None), |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | fn parse_filter_spec_lzma(spec: &PyObjectRef, vm: &VirtualMachine) -> PyResult<LzmaOptions> { |
| 237 | let preset = get_dict_opt_u32(spec, "preset", vm)?.unwrap_or(PRESET_DEFAULT); |
no test coverage detected