o Ec@sddlZddlZddlZddlmZddlmZmZmZm Z m Z ddl m Z ddl mZddlmZmZddlmZmZddlmZeeZGd d d eZGd d d eZd e edfde edfdefddZdeedeefddZdeedededefddZ dS)N)Values)IteratorList NamedTupleOptionalTuplecanonicalize_name)Command)ERRORSUCCESS)BaseDistributionget_default_environment) write_outputc@s<eZdZdZdZdZd ddZded ee de fd d Z dS) ShowCommandzx Show information about one or more installed packages. The output is in RFC-compliant mail header format. z$ %prog [options] ...TreturnNcCs,|jjddddddd|jd|jdS) Nz-fz--filesfiles store_trueFz7Show the full list of installed files for each package.)destactiondefaulthelpr)Zcmd_optsZ add_optionparserZinsert_option_group)selfrN/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/commands/show.py add_optionss zShowCommand.add_optionsoptionsargscCs8|s tdtS|}t|}t||j|jdstStS)Nz.ERROR: Please provide a package name or names.) list_filesverbose)loggerwarningr search_packages_info print_resultsrr r )rrrqueryresultsrrrrun(s  zShowCommand.run)rN) __name__ __module__ __qualname____doc__ZusageZignore_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*r,__annotations__rrrrrrr.6s     r.entry.inforcCsj|r)|ddkr)|r|ddkr|d7}n|dd}|dd}|r)|ddksttjg||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..)r@Nr,pathlibPath)r>r?rrr_convert_legacy_entryHs   rFr%c#st}dd|Ddd|D}tfddt||D}|r-tdd|dtd tt ffd d }d td t tt fd d}d td t tt fdd}|D]}z|}Wn t ygYqVwtdd| Dt j d} t||t j d} z |d} | jdd} Wn tyg} Ynw||p||} | durd}nt| }|j}t|jt |j|jpd| | |j|jpd|dg|dd|dd|dd|dd|dd| |dVqVdS) 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)rIr/rrr mrLz(search_packages_info..csg|] \}}|vr|qSrr)rIr/ZpkgZ installedrrrMoszPackage(s) not found: %s, current_distrcsfddDS)Nc3s6|]}jdd|Dvr|jdpdVqdS)cSsh|]}t|jqSr)r r/)rIdrrr yszRsearch_packages_info.._get_requiring_packages...NameZUNKNOWNN)rGiter_dependenciesmetadatarHrPrr us  zHsearch_packages_info.._get_requiring_packages..)valuesrVrNrVr_get_requiring_packagests z5search_packages_info.._get_requiring_packagesrJcSs<z|d}Wn tyYdSwddt|DS)NZRECORDcss"|] }tt|dVqdS)rNrC)rIrowrrrrWs zCsearch_packages_info.._files_from_record..) read_textFileNotFoundErrorcsvreader splitlines)rJtextrrr_files_from_record|s  z0search_packages_info.._files_from_recordcsz|d}Wn tyYdSwdd|jddD}|j}|j}|dus+|dur-|Sz t||Wn tyB|YSwj sH|Sfdd|DS)Nzinstalled-files.txtcss|]}|r|VqdSNrrIprrrrWszCsearch_packages_info.._files_from_legacy..Fkeependsc3s$|] }tt|jjVqdSrb)rFrDrEpartsrcZinfo_relrrrWs ) r[r\r_r1Zinfo_directoryrDrE relative_to ValueErrorrg)rJr`pathsrootr?rrhr_files_from_legacys(   z0search_packages_info.._files_from_legacycss|]}|jVqdSrb)r/)rIZreqrrrrWsz'search_packages_info..)keyzentry_points.txtFreNZ ClassifierZSummaryz Home-pageZAuthorz Author-emailZLicense)r/r0r1r2r3r4r5r6r7r8r9r:r;r<r)rZiter_distributionssortedzipr!r"joinr rr,rKeyErrorrTlowerr[r_r\rUr.Zraw_namer0r1r4r5Zget_allget)r%envZ query_namesZmissingrYrarmZ query_namerJr2r3Zentry_points_textr<Z files_iterrrUrrNrr#csb           r# distributionsrr c CsHd}t|D]\}}d}|dkrtdtd|jtd|jtd|jtd|jtd |jtd |jtd |jtd |j td d |j tdd |j |rtd|j td|jtd|jD]}td|qktd|jD] }td|qz|rtd|jdurtdq|jD] }td|qq|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: %srOzRequired-by: %szMetadata-Version: %sz Installer: %sz Classifiers:z %sz Entry-points:zFiles:Nz+Cannot locate RECORD or installed-files.txt) enumeraterr/r0r7r8r9r:r;r1rrr2r3r5r4r6r<stripr) rwrr Zresults_printedirJZ classifierr>linerrrr$s@                r$)!r]ZloggingrDZoptparsertypingrrrrrZpip._vendor.packaging.utilsr Zpip._internal.cli.base_commandr Zpip._internal.cli.status_codesr r Zpip._internal.metadatar rZpip._internal.utils.miscrZ getLoggerr(r!rr.r,rFr#boolr$rrrrs0     %&_