Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
HashMismatch Class Reference
Inheritance diagram for HashMismatch:
Collaboration diagram for HashMismatch:

Public Member Functions

None __init__ (self, Dict[str, List[str]] allowed, Dict[str, "_Hash"] gots)
 
str body (self)
 
- Public Member Functions inherited from HashError
str __str__ (self)
 

Data Fields

 allowed
 
 gots
 
- Data Fields inherited from HashError
 req
 

Static Public Attributes

int order = 4
 
tuple head
 
- Static Public Attributes inherited from HashError
Optional req = None
 
str head = ""
 
int order = -1
 

Protected Member Functions

str _hash_comparison (self)
 
- Protected Member Functions inherited from HashError
str _requirement_name (self)
 

Detailed Description

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.

Definition at line 568 of file exceptions.py.

Constructor & Destructor Documentation

◆ __init__()

None __init__ (   self,
Dict[str, List[str]]  allowed,
Dict[str, "_Hash"]  gots 
)
: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

Definition at line 586 of file exceptions.py.

586 def __init__(self, allowed: Dict[str, List[str]], gots: Dict[str, "_Hash"]) -> None:
587 """
588 :param allowed: A dict of algorithm names pointing to lists of allowed
589 hex digests
590 :param gots: A dict of algorithm names pointing to hashes we
591 actually got from the files under suspicion
592 """
593 self.allowed = allowed
594 self.gots = gots
595

Referenced by Protocol.__init_subclass__().

Here is the caller graph for this function:

Member Function Documentation

◆ _hash_comparison()

str _hash_comparison (   self)
protected
Return a comparison of actual and expected hash values.

Example::

       Expected sha256 abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde
                    or 123451234512345123451234512345123451234512345
            Got        bcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdef

Definition at line 599 of file exceptions.py.

599 def _hash_comparison(self) -> str:
600 """
601 Return a comparison of actual and expected hash values.
602
603 Example::
604
605 Expected sha256 abcdeabcdeabcdeabcdeabcdeabcdeabcdeabcdeabcde
606 or 123451234512345123451234512345123451234512345
607 Got bcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdefbcdef
608
609 """
610
611 def hash_then_or(hash_name: str) -> "chain[str]":
612 # For now, all the decent hashes have 6-char names, so we can get
613 # away with hard-coding space literals.
614 return chain([hash_name], repeat(" or"))
615
616 lines: List[str] = []
617 for hash_name, expecteds in self.allowed.items():
618 prefix = hash_then_or(hash_name)
620 (" Expected {} {}".format(next(prefix), e)) for e in expecteds
621 )
623 " Got {}\n".format(self.gots[hash_name].hexdigest())
624 )
625 return "\n".join(lines)
626
627
for i

◆ body()

str body (   self)
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
    its link already populated by the resolver's _populate_link().

Reimplemented from HashError.

Definition at line 596 of file exceptions.py.

596 def body(self) -> str:
597 return " {}:\n{}".format(self._requirement_name(), self._hash_comparison())
598

Referenced by PreparedRequest.copy(), PreparedRequest.prepare_auth(), and PreparedRequest.prepare_body().

Here is the caller graph for this function:

Field Documentation

◆ allowed

allowed

Definition at line 593 of file exceptions.py.

◆ gots

gots

Definition at line 594 of file exceptions.py.

◆ head

tuple head
static
Initial value:
= (
"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."
)

Definition at line 579 of file exceptions.py.

◆ order

int order = 4
static

Definition at line 578 of file exceptions.py.


The documentation for this class was generated from the following file: