a  ze&@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]/opt/bitninja-python-dojo/embedded/lib/python3.9/site-packages/pip/_internal/commands/show.py add_optionsszShowCommand.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__rrrrrrr33s     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_covert_legacy_entryEs   rK)r(rc#st}dd|Ddd|D}tfddt||D}|rXtdd|ttt dfd d }tt t t d d d }tt t t d dd}|D]}z |}Wnt yYqYn0z| d} | jdd} Wntyg} Yn0||p||} | dur"d} nt| } |j} t|jt |j|jpHddd|D|||j|jpld| 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 isz(search_packages_info..cSsg|] }t|qSrr)rNr4rrr mz(search_packages_info..csg|]\}}|vr|qSrr)rNr4pkg installedrrrQorRzPackage(s) not found: %s, ) current_distrcsfddDS)Ncs2g|]*}jdd|Dvr|jdp,dqS)cSsh|]}t|jqSr)r r4)rNdrrr xszSsearch_packages_info.._get_requiring_packages...NameUNKNOWN)rLiter_dependenciesmetadatarMrWrrrQus  zIsearch_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)rNrowrrr rRzCsearch_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|VqdSNrrNprrrrcrRzCsearch_packages_info.._files_from_legacy..Fkeependsc3s"|]}tt|jjVqdSrk)rKrIrJpartsrlZinfo_relrrrcs) rdrerhr6info_directoryrIrJ relative_to ValueErrorrp)rOripathsrootrDrrqr_files_from_legacys$    z0search_packages_info.._files_from_legacyzentry_points.txtFrnNcSsg|] }|jqSr)r4)rNreqrrrrQrR ClassifierZSummaryz Home-pageZAuthorz Author-emailZLicense)r4r5r6r7r8r9r:r;r<r=r>r?r@rAr)riter_distributionssortedzipr$r%joinr rr1rrKeyErrorrdrhrer]r3raw_namer5r6r\r9r:get_allget)r(envZ query_namesmissingr`rjrwZ query_namerOZentry_points_textrAZ files_iterrr]rrTrr&`sZ                 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@r6r~r7r8r: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&     ""b