| 200 | }) |
| 201 | } |
| 202 | fn prase_lineterminator_from_obj(vm: &VirtualMachine, obj: &PyObject) -> PyResult<Terminator> { |
| 203 | match_class!(match obj.get_attr("lineterminator", vm)? { |
| 204 | s @ PyStr => { |
| 205 | Ok(if s.as_bytes().eq(b"\r\n") { |
| 206 | csv_core::Terminator::CRLF |
| 207 | } else if let Some(t) = s.as_bytes().first() { |
| 208 | // Due to limitations in the current implementation within csv_core |
| 209 | // the support for multiple characters in lineterminator is not complete. |
| 210 | // only capture the first character |
| 211 | csv_core::Terminator::Any(*t) |
| 212 | } else { |
| 213 | return Err(new_csv_error(vm, r#""lineterminator" must be a string"#)); |
| 214 | }) |
| 215 | } |
| 216 | attr => { |
| 217 | Err(vm.new_type_error(format!( |
| 218 | r#""lineterminator" must be a string, not {}"#, |
| 219 | attr.class() |
| 220 | ))) |
| 221 | } |
| 222 | }) |
| 223 | } |
| 224 | fn prase_quoting_from_obj(vm: &VirtualMachine, obj: &PyObject) -> PyResult<QuoteStyle> { |
| 225 | match_class!(match obj.get_attr("quoting", vm)? { |
| 226 | i @ PyInt => { |