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

Function register_dialect

crates/stdlib/src/csv.rs:267–289  ·  view source on GitHub ↗
(
        name: PyObjectRef,
        dialect: OptionalArg<PyObjectRef>,
        opts: FormatOptions,
        // TODO: handle quote style, etc
        mut _rest: FuncArgs,
        vm: &VirtualMachine,

Source from the content-addressed store, hash-verified

265
266 #[pyfunction]
267 fn register_dialect(
268 name: PyObjectRef,
269 dialect: OptionalArg<PyObjectRef>,
270 opts: FormatOptions,
271 // TODO: handle quote style, etc
272 mut _rest: FuncArgs,
273 vm: &VirtualMachine,
274 ) -> PyResult<()> {
275 let name = name
276 .downcast::<PyStr>()
277 .map_err(|_| vm.new_type_error("argument 0 must be a string"))?;
278 let name: PyUtf8StrRef = name.try_into_utf8(vm)?;
279 let dialect = match dialect {
280 OptionalArg::Present(d) => PyDialect::try_from_object(vm, d)
281 .map_err(|_| vm.new_type_error("argument 1 must be a dialect object"))?,
282 OptionalArg::Missing => opts.result(vm)?,
283 };
284 let dialect = opts.update_py_dialect(dialect);
285 GLOBAL_HASHMAP
286 .lock()
287 .insert(name.as_str().to_owned(), dialect);
288 Ok(())
289 }
290
291 #[pyfunction]
292 fn get_dialect(

Callers 1

csv.pyFile · 0.85

Calls 7

try_into_utf8Method · 0.80
update_py_dialectMethod · 0.80
resultMethod · 0.45
insertMethod · 0.45
lockMethod · 0.45
to_ownedMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected