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

Function getgrgid

crates/stdlib/src/grp.rs:49–67  ·  view source on GitHub ↗
(gid: PyIntRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

47
48 #[pyfunction]
49 fn getgrgid(gid: PyIntRef, vm: &VirtualMachine) -> PyResult<GroupData> {
50 let gr_gid = gid.as_bigint();
51 let gid = libc::gid_t::try_from(gr_gid)
52 .map(unistd::Gid::from_raw)
53 .ok();
54 let group = gid
55 .map(unistd::Group::from_gid)
56 .transpose()
57 .map_err(|err| err.into_pyexception(vm))?
58 .flatten();
59 let group = group.ok_or_else(|| {
60 vm.new_key_error(
61 vm.ctx
62 .new_str(format!("getgrgid: group id {gr_gid} not found"))
63 .into(),
64 )
65 })?;
66 Ok(GroupData::from_unistd_group(group, vm))
67 }
68
69 #[pyfunction]
70 fn getgrnam(name: PyUtf8StrRef, vm: &VirtualMachine) -> PyResult<GroupData> {

Callers

nothing calls this directly

Calls 8

as_bigintMethod · 0.80
okMethod · 0.80
ok_or_elseMethod · 0.80
new_key_errorMethod · 0.80
mapMethod · 0.45
flattenMethod · 0.45
into_pyexceptionMethod · 0.45
new_strMethod · 0.45

Tested by

no test coverage detected