Merging upstream version 26.26.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
768f936511
commit
1ac9fca060
62 changed files with 938 additions and 453 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::settings::TokenType;
|
||||
use pyo3::prelude::*;
|
||||
use pyo3::types::{PyList, PyString};
|
||||
use pyo3::{pyclass, Py, PyObject, Python};
|
||||
use pyo3::{pyclass, pymethods, Py, PyObject, Python};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[pyclass]
|
||||
|
@ -57,3 +57,25 @@ impl Token {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
impl Token {
|
||||
fn __repr__(&self, py: Python) -> PyResult<String> {
|
||||
let text = self.text.bind(py).to_str()?;
|
||||
let comments = self.comments.bind(py);
|
||||
let token_type_str = self.token_type_py.bind(py).str()?;
|
||||
let comments_repr = comments.repr()?;
|
||||
let comments_str = comments_repr.to_str()?;
|
||||
|
||||
Ok(format!(
|
||||
"<Token token_type: {}, text: {}, line: {}, col: {}, start: {}, end: {}, comments: {}>",
|
||||
token_type_str,
|
||||
text,
|
||||
self.line,
|
||||
self.col,
|
||||
self.start,
|
||||
self.end,
|
||||
comments_str
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue