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

Function writer

crates/stdlib/src/csv.rs:390–413  ·  view source on GitHub ↗
(
        file: PyObjectRef,
        options: FormatOptions,
        // TODO: handle quote style, etc
        _rest: FuncArgs,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

388
389 #[pyfunction]
390 fn writer(
391 file: PyObjectRef,
392 options: FormatOptions,
393 // TODO: handle quote style, etc
394 _rest: FuncArgs,
395 vm: &VirtualMachine,
396 ) -> PyResult<Writer> {
397 let write = match vm.get_attribute_opt(file.clone(), "write")? {
398 Some(write_meth) => write_meth,
399 None if file.is_callable() => file,
400 None => {
401 return Err(vm.new_type_error("argument 1 must have a \"write\" method"));
402 }
403 };
404
405 Ok(Writer {
406 write,
407 state: PyMutex::new(WriteState {
408 buffer: vec![0; 1024],
409 writer: options.to_writer(),
410 }),
411 dialect: options.result(vm)?,
412 })
413 }
414
415 #[inline]
416 fn resize_buf<T: num_traits::PrimInt>(buf: &mut Vec<T>) {

Callers

nothing calls this directly

Calls 7

newFunction · 0.85
get_attribute_optMethod · 0.80
is_callableMethod · 0.80
to_writerMethod · 0.80
ErrClass · 0.50
cloneMethod · 0.45
resultMethod · 0.45

Tested by

no test coverage detected