a Re@sddlZddlZddlZddlmZddlmZmZmZm Z m Z ddl m Z ddl mZddlmZmZddlmZmZddlmZeeZGd d d eZGd d d eZe ed fe ed fedddZeeeedddZeeeeedddZ dS)N)Values)IteratorList NamedTupleOptionalTuplecanonicalize_name)Command)ERRORSUCCESS)BaseDistributionget_default_environment) write_outputc@s<eZdZdZdZdZddddZeee e dd d Z dS) ShowCommandzx Show information about one or more installed packages. The output is in RFC-compliant mail header format. z$ %prog [options] ...TN)returncCs,|jjddddddd|jd|jdS) Nz-fz--filesfiles store_trueFz7Show the full list of installed files for each package.)destactiondefaulthelpr)cmd_opts add_optionparserinsert_option_group)selfr/builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/commands/show.py add_optionss zShowCommand.add_options)optionsargsrcCs8|stdtS|}t|}t||j|jds4tStS)Nz.ERROR: Please provide a package name or names.) list_filesverbose)loggerwarningr search_packages_info print_resultsrr#r )rr r!queryresultsrrrrun(s  zShowCommand.run) __name__ __module__ __qualname____doc__usageignore_require_venvrrrstrintr*rrrrrs  rc@seZdZUeed<eed<eed<eeed<eeed<eed<eed<eeed<eed <eed <eed <eed <eed <eeed<eeeed<dS) _PackageInfonameversionlocationrequires required_by installermetadata_version classifierssummaryhomepageauthor author_emaillicense entry_pointsrN)r+r,r-r1__annotations__rrrrrrr36s     r3.)entryinforcCs\|rD|ddkrD|r |ddkr*|d7}n |dd}|dd}qttjg||RS)aConvert a legacy installed-files.txt path into modern RECORD path. The legacy format stores paths relative to the info directory, while the modern format stores paths relative to the package root, e.g. the site-packages directory. :param entry: Path parts of the installed-files.txt entry. :param info: Path parts of the egg-info directory relative to package root. :returns: The converted entry. For best compatibility with symlinks, this does not use ``abspath()`` or ``Path.resolve()``, but tries to work with path parts: 1. While ``entry`` starts with ``..``, remove the equal amounts of parts from ``info``; if ``info`` is empty, start appending ``..`` instead. 2. Join the two directly. r..)rENr1pathlibPath)rCrDrrr_convert_legacy_entryHs   rK)r(rc#st}dd|Ddd|D}tfddt||D}|rXtdd|ttt dfd d }tt tt d d d }tt tt d dd}|D],}z |}Wnt yYqYn0tdd| Dt j d} t||t j d} z|d} | jdd} Wnty.g} Yn0||p@||} | durRd}nt| }|j}t|jt |j|jpxd| | |j|jpd|dg|dd|dd|dd|dd|dd| |dVqdS)z Gather details from installed distributions. Print distribution name, version, location, and installed files. Installed files requires a pip generated 'installed-files.txt' in the distributions '.egg-info' directory. cSsi|] }|j|qSr)canonical_name.0distrrr lz(search_packages_info..cSsg|] }t|qSrr)rNr4rrr mrQz(search_packages_info..csg|]\}}|vr|qSrr)rNr4pkg installedrrrRorQzPackage(s) not found: %s, ) current_distrcsfddDS)Nc3s4|],}jdd|Dvr|jdp*dVqdS)cSsh|]}t|jqSr)r r4)rNdrrr yrQzRsearch_packages_info.._get_requiring_packages...NameUNKNOWNN)rLiter_dependenciesmetadatarMrWrr us zHsearch_packages_info.._get_requiring_packages..)valuesr^rTr^r_get_requiring_packagests z5search_packages_info.._get_requiring_packages)rOrcSs<z|d}Wnty"YdS0ddt|DS)NRECORDcss |]}tt|dVqdS)rNrH)rNrowrrrr_rQzCsearch_packages_info.._files_from_record..) read_textFileNotFoundErrorcsvreader splitlines)rOtextrrr_files_from_record|s  z0search_packages_info.._files_from_recordcsz|d}Wnty"YdS0dd|jddD}|j}|j}|dusV|durZ|Szt||Wnty|YS0j s|Sfdd|DS)Nzinstalled-files.txtcss|]}|r|VqdSNrrNprrrr_rQzCsearch_packages_info.._files_from_legacy..Fkeependsc3s"|]}tt|jjVqdSrk)rKrIrJpartsrlZinfo_relrrr_s) rdrerhr6info_directoryrIrJ relative_to ValueErrorrp)rOripathsrootrDrrqr_files_from_legacys$    z0search_packages_info.._files_from_legacycss|] }|jVqdSrk)r4)rNreqrrrr_rQz'search_packages_info..)keyzentry_points.txtFrnN ClassifierZSummaryz Home-pageZAuthorz Author-emailZLicense)r4r5r6r7r8r9r:r;r<r=r>r?r@rAr)riter_distributionssortedzipr$r%joinr rr1rKeyErrorr\lowerrdrhrer]r3raw_namer5r6r9r:get_allget)r(envZ query_namesmissingrarjrwZ query_namerOr7r8Zentry_points_textrAZ files_iterrr]rrTrr&csZ               r&) distributionsr"r#rc CsPd}t|D]<\}}d}|dkr*tdtd|jtd|jtd|jtd|jtd |jtd |jtd |jtd |j td d |j tdd |j |r td|j td|jtd|jD]}td|qtd|jD]}td|q|r td|jdur.tdq |jD]}td|q4q |S)zC Print the information from installed distributions found. FTrz---zName: %sz Version: %sz Summary: %sz Home-page: %sz Author: %szAuthor-email: %sz License: %sz Location: %sz Requires: %srVzRequired-by: %szMetadata-Version: %sz Installer: %sz Classifiers:z %sz Entry-points:zFiles:Nz+Cannot locate RECORD or installed-files.txt) enumeraterr4r5r<r=r>r?r@r6rr7r8r:r9r;rAstripr) rr"r#Zresults_printedirO classifierrClinerrrr's>                r')!rfloggingrIoptparsertypingrrrrrpip._vendor.packaging.utilsr pip._internal.cli.base_commandr pip._internal.cli.status_codesr r pip._internal.metadatar rpip._internal.utils.miscr getLoggerr+r$rr3r1rKr&boolr'rrrrs&     %"`