fn read_metadata_for_wheel(path: impl AsRef<Path>) -> Result<Vec<(String, String)>> {
    let filename = filename_from_file(&path)?
        .strip_suffix(".whl")
        // We checked that before entering this function
        .unwrap()
        .to_string();
    let parts: Vec<_> = filename.split('-').collect();
    let dist_name_version = match parts.as_slice() {
        [name, version, _python_tag, _abi_tag, _platform_tag] => format!("{}-{}", name, version),
        _ => bail!("The wheel name is invalid: {}", filename),
    };
    let reader = BufReader::new(File::open(path.as_ref())?);
    let mut archive = ZipArchive::new(reader).context("Failed to read file as zip")?;
    // The METADATA format is an email (RFC 822)
    // pip's implementation: https://github.com/pypa/pip/blob/b33e791742570215f15663410c3ed987d2253d5b/src/pip/_internal/utils/wheel.py#L109-L144
    // twine's implementation: https://github.com/pypa/twine/blob/534385596820129b41cbcdcc83d34aa8788067f1/twine/wheel.py#L52-L56
    // We mostly follow pip
    let name = format!("{}.dist-info/METADATA", dist_name_version);
    let mut metadata_email = Vec::new();

    // Find the metadata file
    let metadata_files: Vec<_> = archive
        .file_names()
        .filter(|i| canonicalize_name(i) == canonicalize_name(&name))
        .map(ToString::to_string)
        .collect();

    match &metadata_files.as_slice() {
        [] => bail!(
            "This wheel does not contain a METADATA matching {}, which is mandatory for wheels",
            name
        ),
        [metadata_file] => archive
            .by_name(&metadata_file)
            .context(format!("Failed to read METADATA file {}", metadata_file))?
            .read_to_end(&mut metadata_email)
            .context(format!("Failed to read METADATA file {}", metadata_file))?,
        files => bail!(
            "Found more than one metadata file matching {}: {:?}",
            name,
            files
        ),
    };

    metadata_from_bytes(&mut metadata_email)
}
/// Reads the METADATA file in the .dist-info directory of a wheel, returning
/// the metadata (https://packaging.python.org/specifications/core-metadata/)
/// as key value pairs
Reads the METADATA file in the .dist-info directory of a wheel, returning
the metadata
as key value pairs
Reads the METADATA file in the . dist - info directory of a wheel returning the metadata as key value pairs
fn read_metadata_for_wheel(path: impl AsRef<Path>) -> Result<Vec<(String, String)>> {
    let filename = filename_from_file(&path)?
        .strip_suffix(".whl")
        // We checked that before entering this function
        .unwrap()
        .to_string();
    let parts: Vec<_> = filename.split('-').collect();
    let dist_name_version = match parts.as_slice() {
        [name, version, _python_tag, _abi_tag, _platform_tag] => format!("{}-{}", name, version),
        _ => bail!("The wheel name is invalid: {}", filename),
    };
    let reader = BufReader::new(File::open(path.as_ref())?);
    let mut archive = ZipArchive::new(reader).context("Failed to read file as zip")?;
    // The METADATA format is an email (RFC 822)
    // pip's implementation: https://github.com/pypa/pip/blob/b33e791742570215f15663410c3ed987d2253d5b/src/pip/_internal/utils/wheel.py#L109-L144
    // twine's implementation: https://github.com/pypa/twine/blob/534385596820129b41cbcdcc83d34aa8788067f1/twine/wheel.py#L52-L56
    // We mostly follow pip
    let name = format!("{}.dist-info/METADATA", dist_name_version);
    let mut metadata_email = Vec::new();
    // Find the metadata file
    let metadata_files: Vec<_> = archive
        .file_names()
        .filter(|i| canonicalize_name(i) == canonicalize_name(&name))
        .map(ToString::to_string)
        .collect();
    match &metadata_files.as_slice() {
        [] => bail!(
            "This wheel does not contain a METADATA matching {}, which is mandatory for wheels",
            name
        ),
        [metadata_file] => archive
            .by_name(&metadata_file)
            .context(format!("Failed to read METADATA file {}", metadata_file))?
            .read_to_end(&mut metadata_email)
            .context(format!("Failed to read METADATA file {}", metadata_file))?,
        files => bail!(
            "Found more than one metadata file matching {}: {:?}",
            name,
            files
        ),
    };
    metadata_from_bytes(&mut metadata_email)
}
fn read_metadata_for_wheel ( path : impl AsRef < Path > ) -> Result < Vec < ( String , String ) > > { let filename = filename_from_file ( & path ) ? . strip_suffix ( " " ) // We checked that before entering this function . unwrap ( ) . to_string ( ) ; let parts : Vec < _ > = filename . split ( '-' ) . collect ( ) ; let dist_name_version = match parts . as_slice ( ) { [ name , version , _python_tag , _abi_tag , _platform_tag ] => format ! ( " " name version ) , _ => bail ! ( " " filename ) , } ; let reader = BufReader :: new ( File :: open ( path . as_ref ( ) ) ? ) ; let mut archive = ZipArchive :: new ( reader ) . context ( " " ) ? ; // The METADATA format is an email (RFC 822) // pip's implementation: https://github.com/pypa/pip/blob/b33e791742570215f15663410c3ed987d2253d5b/src/pip/_internal/utils/wheel.py#L109-L144 // twine's implementation: https://github.com/pypa/twine/blob/534385596820129b41cbcdcc83d34aa8788067f1/twine/wheel.py#L52-L56 // We mostly follow pip let name = format ! ( " " dist_name_version ) ; let mut metadata_email = Vec :: new ( ) ; // Find the metadata file let metadata_files : Vec < _ > = archive . file_names ( ) . filter ( | i | canonicalize_name ( i ) == canonicalize_name ( & name ) ) . map ( ToString :: to_string ) . collect ( ) ; match & metadata_files . as_slice ( ) { [ ] => bail ! ( " " name ) , [ metadata_file ] => archive . by_name ( & metadata_file ) . context ( format ! ( " " metadata_file ) ) ? . read_to_end ( & mut metadata_email ) . context ( format ! ( " " metadata_file ) ) ? , files => bail ! ( " " name files ) , } ; metadata_from_bytes ( & mut metadata_email ) }
Reads the METADATA file in the .dist-info directory of a wheel, returning
the metadata (https://packaging.python.org/specifications/core-metadata/)
as key value pairs
Reads the METADATA file in the . dist - info directory of a wheel returning the metadata ( https : // packaging . python . org / specifications / core - metadata / ) as key value pairs
path
impl AsRef<Path>
path
impl AsRef<Path>