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

Method get_attr

crates/wasm/src/browser_module.rs:200–210  ·  view source on GitHub ↗
(
            &self,
            attr: PyStrRef,
            default: OptionalArg<PyObjectRef>,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

198 impl Element {
199 #[pymethod]
200 fn get_attr(
201 &self,
202 attr: PyStrRef,
203 default: OptionalArg<PyObjectRef>,
204 vm: &VirtualMachine,
205 ) -> PyObjectRef {
206 match self.elem.get_attribute(attr.expect_str()) {
207 Some(s) => vm.ctx.new_str(s).into(),
208 None => default.unwrap_or_none(vm),
209 }
210 }
211
212 #[pymethod]
213 fn set_attr(&self, attr: PyStrRef, value: PyStrRef, vm: &VirtualMachine) -> PyResult<()> {

Callers 2

inject_moduleMethod · 0.45
inject_js_moduleMethod · 0.45

Calls 3

expect_strMethod · 0.80
new_strMethod · 0.45
unwrap_or_noneMethod · 0.45

Tested by

no test coverage detected