rust/hg-cpython/src/filepatterns.rs
branchstable
changeset 43465 a264e8a91798
parent 42960 7a01778bc7b7
child 43466 4f1cddd1939e
equal deleted inserted replaced
43464:578c42f998d9 43465:a264e8a91798
    11 //! and can be used as replacement for the the pure `filepatterns` Python
    11 //! and can be used as replacement for the the pure `filepatterns` Python
    12 //! module.
    12 //! module.
    13 //!
    13 //!
    14 use crate::exceptions::{PatternError, PatternFileError};
    14 use crate::exceptions::{PatternError, PatternFileError};
    15 use cpython::{
    15 use cpython::{
    16     PyBytes, PyDict, PyModule, PyObject, PyResult, PyString, PyTuple, Python,
    16     PyBytes, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, ToPyObject,
    17     ToPyObject,
       
    18 };
    17 };
    19 use hg::{
    18 use hg::{
    20     build_single_regex, read_pattern_file, utils::files::get_path_from_bytes,
    19     build_single_regex, read_pattern_file, utils::files::get_path_from_bytes,
    21     LineNumber, PatternTuple,
    20     LineNumber, PatternTuple,
    22 };
    21 };
    64 }
    63 }
    65 
    64 
    66 fn warnings_to_py_bytes(
    65 fn warnings_to_py_bytes(
    67     py: Python,
    66     py: Python,
    68     warnings: &[(PathBuf, Vec<u8>)],
    67     warnings: &[(PathBuf, Vec<u8>)],
    69 ) -> Vec<(PyString, PyBytes)> {
    68 ) -> Vec<(PyBytes, PyBytes)> {
    70     warnings
    69     warnings
    71         .iter()
    70         .iter()
    72         .map(|(path, syn)| {
    71         .map(|(path, syn)| {
    73             (
    72             (
    74                 PyString::new(py, &path.to_string_lossy()),
    73                 PyBytes::new(py, &path.to_string_lossy().as_bytes()),
    75                 PyBytes::new(py, syn),
    74                 PyBytes::new(py, syn),
    76             )
    75             )
    77         })
    76         })
    78         .collect()
    77         .collect()
    79 }
    78 }