pub fn find_installed(lib_path: &Path) -> Vec<(String, Version, Vec<String>)> {
    if !lib_path.exists() {
        return vec![];
    }

    let mut result = vec![];

    for folder_name in &find_folders(&lib_path) {
        let re_dist = Regex::new(r"^(.*?)-(.*?)\.dist-info$").unwrap();

        if let Some(caps) = re_dist.captures(folder_name) {
            let name = caps.get(1).unwrap().as_str();
            let vers = Version::from_str(
                caps.get(2)
                    .expect("Problem parsing version in folder name")
                    .as_str(),
            )
            .expect("Problem parsing version in package folder");

            let top_level = lib_path.join(folder_name).join("top_level.txt");

            let mut tops = vec![];
            match fs::File::open(top_level) {
                Ok(f) => {
                    for line in BufReader::new(f).lines() {
                        if let Ok(l) = line {
                            tops.push(l);
                        }
                    }
                }
                Err(_) => tops.push(folder_name.to_owned()),
            }

            result.push((name.to_owned(), vers, tops));
        }
    }
    result
}
/// Find the packages installed, by browsing the lib folder for metadata.
/// Returns package-name, version, folder names
Find the packages installed, by browsing the lib folder for metadata.
Returns package-name, version, folder names
Find the packages installed by browsing the lib folder for metadata . Returns package - name version folder names
pub fn find_installed(lib_path: &Path) -> Vec<(String, Version, Vec<String>)> {
    if !lib_path.exists() {
        return vec![];
    }
    let mut result = vec![];
    for folder_name in &find_folders(&lib_path) {
        let re_dist = Regex::new(r"^(.*?)-(.*?)\.dist-info$").unwrap();
        if let Some(caps) = re_dist.captures(folder_name) {
            let name = caps.get(1).unwrap().as_str();
            let vers = Version::from_str(
                caps.get(2)
                    .expect("Problem parsing version in folder name")
                    .as_str(),
            )
            .expect("Problem parsing version in package folder");
            let top_level = lib_path.join(folder_name).join("top_level.txt");
            let mut tops = vec![];
            match fs::File::open(top_level) {
                Ok(f) => {
                    for line in BufReader::new(f).lines() {
                        if let Ok(l) = line {
                            tops.push(l);
                        }
                    }
                }
                Err(_) => tops.push(folder_name.to_owned()),
            }
            result.push((name.to_owned(), vers, tops));
        }
    }
    result
}
pub fn find_installed ( lib_path : & Path ) -> Vec < ( String , Version , Vec < String > ) > { if ! lib_path . exists ( ) { return vec ! [ ] ; } let mut result = vec ! [ ] ; for folder_name in & find_folders ( & lib_path ) { let re_dist = Regex :: new ( r"^(.*?)-(.*?)\.dist-info$" ) . unwrap ( ) ; if let Some ( caps ) = re_dist . captures ( folder_name ) { let name = caps . get ( 1 ) . unwrap ( ) . as_str ( ) ; let vers = Version :: from_str ( caps . get ( 2 ) . expect ( " " ) . as_str ( ) , ) . expect ( " " ) ; let top_level = lib_path . join ( folder_name ) . join ( " " ) ; let mut tops = vec ! [ ] ; match fs :: File :: open ( top_level ) { Ok ( f ) => { for line in BufReader :: new ( f ) . lines ( ) { if let Ok ( l ) = line { tops . push ( l ) ; } } } Err ( _ ) => tops . push ( folder_name . to_owned ( ) ) , } result . push ( ( name . to_owned ( ) , vers , tops ) ) ; } } result }
Find the packages installed, by browsing the lib folder for metadata.
Find the packages installed by browsing the lib folder for metadata .
lib_path
&Path