ôY¹ã@sèdZddlmZddlmZmZmZddlmZGdd„de ƒZ Gdd„de ƒZ Gd d „d e ƒZ Gd d „d e ƒZ Gd d„de ƒZGdd„de ƒZGdd„de ƒZGdd„de ƒZGdd„de ƒZGdd„de ƒZGdd„de ƒZGdd„de ƒZGdd„de ƒZGdd „d eƒZGd!d"„d"eƒZGd#d$„d$eƒZGd%d&„d&eƒZGd'd(„d(eƒZGd)d*„d*e ƒZd+S),z"Exceptions used throughout packageé)Úabsolute_import)ÚchainÚgroupbyÚrepeat)Ú iteritemsc@seZdZdZdS)ÚPipErrorzBase pip exceptionN)Ú__name__Ú __module__Ú __qualname__Ú__doc__©r r ú-/tmp/pip-build-3puug3g5/pip/pip/exceptions.pyr s rc@seZdZdZdS)ÚInstallationErrorz%General exception during installationN)rr r r r r r r r s rc@seZdZdZdS)ÚUninstallationErrorz'General exception during uninstallationN)rr r r r r r r rs rc@seZdZdZdS)ÚDistributionNotFoundzCRaised when a distribution cannot be found to satisfy a requirementN)rr r r r r r r rs rc@seZdZdZdS)ÚRequirementsFileParseErrorzDRaised when a general error occurs parsing a requirements file line.N)rr r r r r r r rs rc@seZdZdZdS)ÚBestVersionAlreadyInstalledzNRaised when the most up-to-date version of a package is already installed.N)rr r r r r r r rs rc@seZdZdZdS)Ú BadCommandz0Raised when virtualenv or a command is not foundN)rr r r r r r r r"s rc@seZdZdZdS)Ú CommandErrorz7Raised when there is an error in command-line argumentsN)rr r r r r r r r&s rc@seZdZdZdS)ÚPreviousBuildDirErrorz:Raised when there's a previous conflicting build directoryN)rr r r r r r r r*s rc@seZdZdZdS)ÚInvalidWheelFilenamezInvalid wheel filename.N)rr r r r r r r r.s rc@seZdZdZdS)ÚUnsupportedWheelzUnsupported wheel.N)rr r r r r r r r2s rc@sReZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd S) Ú HashErrorsz:Multiple HashError instances rolled into one for reportingcCs g|_dS)N)Úerrors)Úselfr r r Ú__init__9szHashErrors.__init__cCs|jj|ƒdS)N)rÚappend)rÚerrorr r r r<szHashErrors.appendcCs‰g}|jjddd„ƒxPt|jdd„ƒD]6\}}|j|jƒ|jdd„|Dƒƒq8W|r…dj|ƒSdS)NÚkeycSs|jS)N)Úorder)Úer r r ÚAsz$HashErrors.__str__..cSs|jS)N)Ú __class__)r r r r r!Bscss|]}|jƒVqdS)N)Úbody)Ú.0r r r r ú Dsz%HashErrors.__str__..Ú )rÚsortrrÚheadÚextendÚjoin)rÚlinesÚclsÚ errors_of_clsr r r Ú__str__?s%zHashErrors.__str__cCs t|jƒS)N)Úboolr)rr r r Ú __nonzero__HszHashErrors.__nonzero__cCs |jƒS)N)r0)rr r r Ú__bool__KszHashErrors.__bool__N) rr r r rrr.r0r1r r r r r6s    rc@sFeZdZdZdZdZdd„Zdd„Zdd „ZdS) Ú HashErrora” A failure to verify a package against known-good hashes :cvar order: An int sorting hash exception classes by difficulty of recovery (lower being harder), so the user doesn't bother fretting about unpinned packages when he has deeper issues, like VCS dependencies, to deal with. Also keeps error reports in a deterministic order. :cvar head: A section heading for display above potentially many exceptions of this kind :ivar req: The InstallRequirement that triggered this error. This is pasted on after the exception is instantiated, because it's not typically available earlier. NÚcCsd|jƒS)a)Return a summary of me for display under the heading. This default implementation simply prints a description of the triggering requirement. :param req: The InstallRequirement that provoked this error, with populate_link() having already been called z %s)Ú_requirement_name)rr r r r#bs zHashError.bodycCsd|j|jƒfS)Nz%s %s)r(r#)rr r r r.nszHashError.__str__cCs|jrt|jƒSdS)z¨Return a description of the requirement that triggered me. This default implementation returns long description of the req, with line numbers zunknown package)ÚreqÚstr)rr r r r4qszHashError._requirement_name) rr r r r5r(r#r.r4r r r r r2Os  r2c@s"eZdZdZdZdZdS)ÚVcsHashUnsupportedzuA hash was provided for a version-control-system-based requirement, but we don't have a method for hashing those.rzlCan't verify hashes for these requirements because we don't have a way to hash version control repositories:N)rr r r rr(r r r r r7{s r7c@s"eZdZdZdZdZdS)ÚDirectoryUrlHashUnsupportedzuA hash was provided for a version-control-system-based requirement, but we don't have a method for hashing those.ézUCan't verify hashes for these file:// requirements because they point to directories:N)rr r r rr(r r r r r8„s r8c@s:eZdZdZdZdZdd„Zdd„ZdS) Ú HashMissingz2A hash was needed for a requirement but is absent.éawHashes are required in --require-hashes mode, but they are missing from some requirements. Here is a list of those requirements along with the hashes their downloaded archives actually had. Add lines like these to your requirements files to prevent tampering. (If you did not enable --require-hashes manually, note that it turns on automatically when any package has a hash.)cCs ||_dS)zq :param gotten_hash: The hash of the (possibly malicious) archive we just downloaded N)Ú gotten_hash)rr<r r r r™szHashMissing.__init__cCsfddlm}d}|jrL|jjr7|jjnt|jddƒ}d|pXd||jfS)Nr)Ú FAVORITE_HASHr5z %s --hash=%s:%szunknown package)Úpip.utils.hashesr=r5Ú original_linkÚgetattrr<)rr=Úpackager r r r# s  zHashMissing.bodyN)rr r r rr(rr#r r r r r:s  r:c@s"eZdZdZdZdZdS)Ú HashUnpinnedzPA requirement had a hash specified but was not pinned to a specific version.ézaIn --require-hashes mode, all requirements must have their versions pinned with ==. These do not:N)rr r r rr(r r r r rB±s rBc@sFeZdZdZdZdZdd„Zdd„Zdd „Zd S) Ú HashMismatchzî Distribution file hash values don't match. :ivar package_name: The name of the package that triggered the hash mismatch. Feel free to write to this after the exception is raise to improve its error message. ézÞTHESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.cCs||_||_dS)zí :param allowed: A dict of algorithm names pointing to lists of allowed hex digests :param gots: A dict of algorithm names pointing to hashes we actually got from the files under suspicion N)ÚallowedÚgots)rrFrGr r r rÉs zHashMismatch.__init__cCsd|jƒ|jƒfS)Nz %s: %s)r4Ú_hash_comparison)rr r r r#Ós zHashMismatch.bodycsdd„}g}xmt|jƒD]\\}}||ƒ‰|j‡fdd†|Dƒƒ|jd|j|jƒƒd‰q"Wdj|ƒS)aE Return a comparison of actual and expected hash values. Example:: Expected sha256 abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde or 123451234512345123451234512345123451234512345 Got bcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdef cSst|gtdƒƒS)Nz or)rr)Ú hash_namer r r Ú hash_then_orâsz3HashMismatch._hash_comparison..hash_then_orc3s%|]}dtˆƒ|fVqdS)z Expected %s %sN)Únext)r$r )Úprefixr r r%êsz0HashMismatch._hash_comparison..z Got %s z orr&)rrFr)rrGÚ hexdigestr*)rrJr+rIÚ expectedsr )rLr rH×s     zHashMismatch._hash_comparisonN) rr r r rr(rr#rHr r r r rDºs  rDc@seZdZdZdS)ÚUnsupportedPythonVersionzMUnsupported python version according to Requires-Python package metadata.N)rr r r r r r r rOòs rON)r Ú __future__rÚ itertoolsrrrÚpip._vendor.sixrÚ Exceptionrrrrrrrrrrrrr2r7r8r:rBrDrOr r r r Ús,,  $ 8