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

Function get_dialect

crates/stdlib/src/csv.rs:292–309  ·  view source on GitHub ↗
(
        name: PyObjectRef,
        mut _rest: FuncArgs,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

290
291 #[pyfunction]
292 fn get_dialect(
293 name: PyObjectRef,
294 mut _rest: FuncArgs,
295 vm: &VirtualMachine,
296 ) -> PyResult<PyDialect> {
297 let name = name.downcast::<PyStr>().map_err(|obj| {
298 new_csv_error(
299 vm,
300 format!("argument 0 must be a string, not '{}'", obj.class()),
301 )
302 })?;
303 let name: PyUtf8StrRef = name.try_into_utf8(vm)?;
304 let g = GLOBAL_HASHMAP.lock();
305 if let Some(dialect) = g.get(name.as_str()) {
306 return Ok(*dialect);
307 }
308 Err(new_csv_error(vm, "unknown dialect"))
309 }
310
311 #[pyfunction]
312 fn unregister_dialect(

Callers

nothing calls this directly

Calls 6

new_csv_errorFunction · 0.85
try_into_utf8Method · 0.80
ErrClass · 0.50
lockMethod · 0.45
getMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected