Show More
@@ -227,7 +227,7 b' lazy_static! {' | |||
|
227 | 227 | } |
|
228 | 228 | |
|
229 | 229 | pub type PatternTuple = (Vec<u8>, LineNumber, Vec<u8>); |
|
230 |
type WarningTuple = ( |
|
|
230 | type WarningTuple = (Vec<u8>, Vec<u8>); | |
|
231 | 231 | |
|
232 | 232 | pub fn parse_pattern_file_contents( |
|
233 | 233 | lines: &[u8], |
@@ -263,10 +263,7 b' pub fn parse_pattern_file_contents(' | |||
|
263 | 263 | if let Some(rel_syntax) = SYNTAXES.get(syntax) { |
|
264 | 264 | current_syntax = rel_syntax; |
|
265 | 265 | } else if warn { |
|
266 | warnings.push(( | |
|
267 | String::from_utf8_lossy(file_path).to_string(), | |
|
268 | String::from_utf8_lossy(syntax).to_string(), | |
|
269 | )); | |
|
266 | warnings.push((file_path.to_owned(), syntax.to_owned())); | |
|
270 | 267 | } |
|
271 | 268 | continue; |
|
272 | 269 | } |
@@ -40,17 +40,31 b' fn read_pattern_file_wrapper(' | |||
|
40 | 40 | }; |
|
41 | 41 | let results: Vec<(PyBytes, LineNumber, PyBytes)> = |
|
42 | 42 | patterns.iter().map(itemgetter).collect(); |
|
43 |
return Ok((results, warnings) |
|
|
43 | return Ok((results, warnings_to_py_bytes(py, &warnings)) | |
|
44 | .to_py_object(py)); | |
|
44 | 45 | } |
|
45 | 46 | let itemgetter = |x: &PatternTuple| PyBytes::new(py, &x.0); |
|
46 | 47 | let results: Vec<PyBytes> = |
|
47 | 48 | patterns.iter().map(itemgetter).collect(); |
|
48 | Ok((results, warnings).to_py_object(py)) | |
|
49 | Ok( | |
|
50 | (results, warnings_to_py_bytes(py, &warnings)) | |
|
51 | .to_py_object(py), | |
|
52 | ) | |
|
49 | 53 | } |
|
50 | 54 | Err(e) => Err(PatternFileError::pynew(py, e)), |
|
51 | 55 | } |
|
52 | 56 | } |
|
53 | 57 | |
|
58 | fn warnings_to_py_bytes( | |
|
59 | py: Python, | |
|
60 | warnings: &[(Vec<u8>, Vec<u8>)], | |
|
61 | ) -> Vec<(PyBytes, PyBytes)> { | |
|
62 | warnings | |
|
63 | .iter() | |
|
64 | .map(|(path, syn)| (PyBytes::new(py, path), PyBytes::new(py, syn))) | |
|
65 | .collect() | |
|
66 | } | |
|
67 | ||
|
54 | 68 | fn build_single_regex_wrapper( |
|
55 | 69 | py: Python, |
|
56 | 70 | kind: PyObject, |
General Comments 0
You need to be logged in to leave comments.
Login now