RebddlZddlZddlZddlmZddlmZmZmZm Z m Z ddl m Z ddl mZddlmZmZddlmZmZddlmZejeZGd d eZGd d eZd e edfde edfdefdZdeedeefdZdeedededefdZ dS)N)Values)IteratorList NamedTupleOptionalTuplecanonicalize_name)Command)ERRORSUCCESS)BaseDistributionget_default_environment) write_outputcBeZdZdZdZdZd dZdedee de fd Z dS) ShowCommandzx Show information about one or more installed packages. The output is in RFC-compliant mail header format. z$ %prog [options] ...TreturnNc|jdddddd|jd|jdS) Nz-fz--filesfiles store_trueFz7Show the full list of installed files for each package.)destactiondefaulthelpr)cmd_opts add_optionparserinsert_option_group)selfs /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/commands/show.py add_optionszShowCommand.add_optionssU    J !    ''4=99999optionsargsc|s!tdtS|}t|}t ||j|jstStS)Nz.ERROR: Please provide a package name or names.) list_filesverbose)loggerwarningr search_packages_info print_resultsrr'r )rr#r$queryresultss r runzShowCommand.run(sb  NNK L L LL&u--  w    Lr")rN) __name__ __module__ __qualname____doc__usageignore_require_venvr!rrstrintr.r"r rrsl  'E : : : : 6 c s      r"rceZdZUeed<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/r0r1r5__annotations__rrr7r"r r9r96s III LLLMMM3icNNNc LLLMMM KKK LLLs) DI r"r9entry.inforc|rB|ddkr6|r |ddkr|dz }n |dd}|dd}|r |ddk6ttjg||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..)rLNr5pathlibPath)rIrJs r _convert_legacy_entryrRHs$ E!H$$ tBx4'' GODD9Dabb  E!H$$ w|*T*E*** + ++r"r,c#hKt}d|Dd|D}tfdt||D}|r.tdd|dtdttffd }d tdtttfd }d tdtttfd }|D]} |}n#t$rYwxYwtd | Dtj } t||tj } |d} | d} n#t $rg} YnwxYw||p ||} | d}nt| }|j}t%|jt|j|jpd| | |j|jpd|dg|dd|dd|dd|dd|dd| |VdS)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. ci|] }|j| Sr7)canonical_name).0dists r z(search_packages_info..lsPPPt$dPPPr"c,g|]}t|Sr7r )rVr:s r z(search_packages_info..ms!===t$T**===r"c"g|] \}}|v | Sr7r7)rVr:pkg installeds r rZz(search_packages_info..os'OOO)$#Y:N:N:N:N:Nr"zPackage(s) not found: %s, current_distrcFfdDS)Nc3K|]8}jd|Dv'|jdpdV9dS)c6h|]}t|jSr7)r r:)rVds r zRsearch_packages_info.._get_requiring_packages...ys#LLLa!!&))LLLr"NameUNKNOWNN)rUiter_dependenciesmetadata)rVrWr_s r zHsearch_packages_info.._get_requiring_packages..usv  *LL43I3I3K3KLLLMM M& ! .YMMMM  r")values)r_r]s`r _get_requiring_packagesz5search_packages_info.._get_requiring_packagests;    !((**    r"rWc |d}n#t$rYdSwxYwdtj|DS)NRECORDc3dK|]+}ttj|dV,dS)rNrO)rVrows r rizCsearch_packages_info.._files_from_record..s8SScGLQ(())SSSSSSr") read_textFileNotFoundErrorcsvreader splitlines)rWtexts r _files_from_recordz0search_packages_info.._files_from_record|sg >>(++DD    44 TSSZ@Q@Q5R5RSSSSs  &&c` |d}n#t$rYdSwxYwd|dD}|j}|j}|||S t j||n#t$r|cYSwxYwj s|Sfd|DS)Nzinstalled-files.txtc3K|]}||V dSNr7)rVps r rizCsearch_packages_info.._files_from_legacy..s'AAqqAAAAAAAr"Fkeependsc3pK|]0}ttj|jjV1dSry)rRrPrQparts)rVrzinfo_rels r rizCsearch_packages_info.._files_from_legacy..sL  MN !',q//"7 H H      r") rprqrtr<info_directoryrPrQ relative_to ValueErrorr~)rWrupathsrootrJrs @r _files_from_legacyz0search_packages_info.._files_from_legacys >>"788DD    44 AADOOUO;;AAA}" <4<L |D))55d;;HH   LLL ~ L    RW    s '''B BBc3$K|] }|jV dSry)r:)rVreqs r riz'search_packages_info..s$HH38HHHHHHr")keyzentry_points.txtFr{N ClassifierSummaryz Home-pageAuthorz Author-emailLicense)r:r;r<r=r>r?r@rArBrCrDrErFrGr)riter_distributionssortedzipr(r)joinrrr5rKeyErrorrglowerrprtrqrhr9raw_namer;r<r?r@get_allget)r,env query_namesmissingrkrvr query_namerWr=r>entry_points_textrG files_iterrrhr]s @r r*r*cs, " # #CPPs7M7M7O7OPPPI==u===KOOOOs5+66OOOGG1499W3E3EFFF .> 8C=      T!1Thx}6MTTTT !1 hx}6M    ("' '  Z(DD    H HHt/E/E/G/GHHHciXXX44T:: JJJ   $/A B B ,777GGLL    LLL ('--I1C1CD1I1I  )-EE:&&E= %%](b#n!28b ((r::LLB//\\+r22<<"--!nb99LLB//%       /' ' s$ D D D ?+F++ F:9F: distributionsr&r'c d}t|D]\}}d}|dkrtdtd|jtd|jtd|jtd|jtd |jtd |jtd |jtd |j td d |j tdd |j |rtd|j td|jtd|jD]}td|td|jD]$}td|%|rStd|jtd|jD]$}td|%|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: %sr^zRequired-by: %szMetadata-Version: %sz Installer: %sz Classifiers:z %sz Entry-points:zFiles:Nz+Cannot locate RECORD or installed-files.txt) enumeraterr:r;rBrCrDrErFr<rr=r>r@r?rArGstripr) rr&r'results_printedirW classifierrIlines r r+r+sO]++774 q55    Z+++]DL111]DL111_dm444\4;///'):;;;]DL111^T]333^TYYt}%=%=>>>& $2B(C(CDDD  4 /1F G G G $. 9 9 9  ( ( (". 1 1 VZ0000  ) ) )* 4 4VU[[]]3333  7  " " "z!JKKKK J77D 6666 r")!rrloggingrPoptparsertypingrrrrrpip._vendor.packaging.utilsr pip._internal.cli.base_commandr pip._internal.cli.status_codesr r pip._internal.metadatarrpip._internal.utils.miscr getLoggerr/r(rr9r5rRr*boolr+r7r"r rs >>>>>>>>>>>>>>99999922222299999999LLLLLLLL111111  8 $ $"""""'"""J:$,sCx,c3h,C,,,,6\ S \ h|.D\ \ \ \ ~)L)))) ))))))r"