o ai@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)cmd_opts add_optionparserinsert_option_group)selfr/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-5.el8.x86_64/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 )rr r!queryresultsrrrrun(s  zShowCommand.run)rN) __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     r3entry.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..)rENr1pathlibPath)rCrDrrr_convert_legacy_entryHs   rKr(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)rNr4rrr mrQz(search_packages_info..csg|] \}}|vr|qSrr)rNr4pkg installedrrrRoszPackage(s) not found: %s, current_distrcsfddDS)Nc3s6|]}jdd|Dvr|jdpdVqdS)cSsh|]}t|jqSr)r r4)rNdrrr yszRsearch_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_packagesrOcSs<z|d}Wn tyYdSwddt|DS)NRECORDcss"|] }tt|dVqdS)rNrH)rNrowrrrr_s zCsearch_packages_info.._files_from_record..) read_textFileNotFoundErrorcsvreader splitlines)rOtextrrr_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|VqdSNrrNprrrr_szCsearch_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_sz'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&csb           r& distributionsr"r#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: %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'rrrrs0     %&_