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

Function parser_create

crates/stdlib/src/pyexpat.rs:399–420  ·  view source on GitHub ↗
(
        args: ParserCreateArgs,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

397
398 #[pyfunction(name = "ParserCreate")]
399 fn parser_create(
400 args: ParserCreateArgs,
401 vm: &VirtualMachine,
402 ) -> PyResult<PyExpatLikeXmlParserRef> {
403 // Validate namespace_separator: must be at most one character
404 let ns_sep = match args.namespace_separator {
405 Some(ref s) => {
406 if s.as_str().chars().count() > 1 {
407 return Err(vm.new_value_error(
408 "namespace_separator must be at most one character, omitted, or None",
409 ));
410 }
411 Some(s.as_str().to_owned())
412 }
413 None => None,
414 };
415
416 // encoding parameter is currently not used (xml-rs handles encoding from XML declaration)
417 let _ = args.encoding;
418
419 PyExpatLikeXmlParser::new(ns_sep, args.intern, vm)
420 }
421
422 // TODO: Tie this exception to the module's state.
423 #[pyattr]

Callers

nothing calls this directly

Calls 7

newFunction · 0.85
charsMethod · 0.80
ErrClass · 0.50
SomeClass · 0.50
countMethod · 0.45
as_strMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected