MCPcopy Index your code
hub / github.com/RustPython/RustPython / _get_proxy_settings

Function _get_proxy_settings

crates/stdlib/src/scproxy.rs:35–67  ·  view source on GitHub ↗
(vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

33
34 #[pyfunction]
35 fn _get_proxy_settings(vm: &VirtualMachine) -> PyResult<Option<PyDictRef>> {
36 let Some(proxy_dict) = proxy_dict() else {
37 return Ok(None);
38 };
39
40 let result = vm.ctx.new_dict();
41
42 let v = 0
43 != proxy_dict
44 .find(unsafe { kSCPropNetProxiesExcludeSimpleHostnames })
45 .and_then(|v| v.downcast::<CFNumber>())
46 .and_then(|v| v.to_i32())
47 .unwrap_or(0);
48 result.set_item("exclude_simple", vm.ctx.new_bool(v).into(), vm)?;
49
50 if let Some(an_array) = proxy_dict
51 .find(unsafe { kSCPropNetProxiesExceptionsList })
52 .and_then(|v| v.downcast::<CFArray>())
53 {
54 let v = an_array
55 .into_iter()
56 .map(|s| {
57 unsafe { CFType::from_void(*s) }
58 .downcast::<CFString>()
59 .map(|s| PyStr::from(s.to_string()))
60 .to_pyobject(vm)
61 })
62 .collect();
63 result.set_item("exceptions", vm.ctx.new_tuple(v).into(), vm)?;
64 }
65
66 Ok(Some(result))
67 }
68
69 #[pyfunction]
70 fn _get_proxies(vm: &VirtualMachine) -> PyResult<Option<PyDictRef>> {

Callers 1

Calls 12

proxy_dictFunction · 0.85
new_dictMethod · 0.80
collectMethod · 0.80
to_stringMethod · 0.80
SomeClass · 0.50
findMethod · 0.45
set_itemMethod · 0.45
new_boolMethod · 0.45
mapMethod · 0.45
into_iterMethod · 0.45
to_pyobjectMethod · 0.45
new_tupleMethod · 0.45

Tested by

no test coverage detected