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

Function getgrnam

crates/stdlib/src/grp.rs:70–84  ·  view source on GitHub ↗
(name: PyUtf8StrRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

68
69 #[pyfunction]
70 fn getgrnam(name: PyUtf8StrRef, vm: &VirtualMachine) -> PyResult<GroupData> {
71 let gr_name = name.as_str();
72 if gr_name.contains('\0') {
73 return Err(exceptions::cstring_error(vm));
74 }
75 let group = unistd::Group::from_name(gr_name).map_err(|err| err.into_pyexception(vm))?;
76 let group = group.ok_or_else(|| {
77 vm.new_key_error(
78 vm.ctx
79 .new_str(format!("getgrnam: group name {gr_name} not found"))
80 .into(),
81 )
82 })?;
83 Ok(GroupData::from_unistd_group(group, vm))
84 }
85
86 #[pyfunction]
87 fn getgrall(vm: &VirtualMachine) -> PyResult<Vec<PyObjectRef>> {

Callers 1

_get_gidFunction · 0.90

Calls 8

cstring_errorFunction · 0.85
ok_or_elseMethod · 0.80
new_key_errorMethod · 0.80
ErrClass · 0.50
as_strMethod · 0.45
containsMethod · 0.45
into_pyexceptionMethod · 0.45
new_strMethod · 0.45

Tested by

no test coverage detected