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

Public Member Functions

None __post_init__ (self)
 
Optional["LinkHash"] find_hash_url_fragment (cls, str url)
 
Dict[str, str] as_dict (self)
 
Hashes as_hashes (self)
 
bool is_hash_allowed (self, Optional[Hashes] hashes)
 

Data Fields

 name
 

Static Public Attributes

str name
 
str value
 

Static Protected Attributes

 _hash_url_fragment_re
 

Detailed Description

Links to content may have embedded hash values. This class parses those.

`name` must be any member of `_SUPPORTED_HASHES`.

This class can be converted to and from `ArchiveInfo`. While ArchiveInfo intends to
be JSON-serializable to conform to PEP 610, this class contains the logic for
parsing a hash name and value for correctness, and then checking whether that hash
conforms to a schema with `.is_hash_allowed()`.

Definition at line 45 of file link.py.

Member Function Documentation

◆ __post_init__()

None __post_init__ (   self)

Definition at line 69 of file link.py.

69 def __post_init__(self) -> None:
70 assert self.name in _SUPPORTED_HASHES
71

References MunitParameterEnum.name, MunitParameter.name, MunitTest.name, MunitArgument_.name, Command.name, ConfigOptionParser.name, TransformedHit.name, _PackageInfo.name, InvalidWheel.name, BaseEntryPoint.name(), BasePath.name(), EntryPoint.name, InstallationCandidate.name, VcsInfo.name, ArchiveInfo.name, DirInfo.name, LinkHash.name, Wheel.name, LazyZipOverHTTP.name(), FrozenRequirement.name, InstallationResult.name, InstallRequirement.name(), InstallRequirement.name, Requirement.name(), Candidate.name(), _InstallRequirementBackedCandidate.name(), _InstallRequirementBackedCandidate.name, AlreadyInstalledCandidate.name, AlreadyInstalledCandidate.name(), ExtrasCandidate.name(), RequiresPythonCandidate.name(), ExplicitRequirement.name(), SpecifierRequirement.name(), RequiresPythonRequirement.name(), UnsatisfiableRequirement.name(), Bazaar.name, Mercurial.name, Subversion.name, VcsSupport.name, VersionControl.name, CodingStateMachineDict.name, Language.name, _Cache.name, Distribution.name, InstalledDistribution.name, EggInfoDistribution.name, LegacyMetadata.name, Metadata.name, ResourceBase.name, ExportEntry.name, Matcher.name, LinuxDistribution.name(), Formatter.name, BBCodeFormatter.name, GroffFormatter.name, HtmlFormatter.name, ImageFormatter.name, GifImageFormatter.name, JpgImageFormatter.name, BmpImageFormatter.name, IRCFormatter.name, LatexFormatter.name, NullFormatter.name, RawTokenFormatter.name, TestcaseFormatter.name, PangoMarkupFormatter.name, RtfFormatter.name, SvgFormatter.name, TerminalFormatter.name, Terminal256Formatter.name, TerminalTrueColorFormatter.name, Lexer.name, PythonLexer.name, Python2Lexer.name, _PythonConsoleLexerBase.name, PythonConsoleLexer.name, PythonTracebackLexer.name, Python2TracebackLexer.name, CythonLexer.name, DgLexer.name, NumPyLexer.name, ParserElement.name(), EditablePartial.name(), ElementState.name, LookupDict.name, Color.name, Emoji.name, Splitter.name, RowSplitter.name, ColumnSplitter.name, Layout.name, Tag.name, StockKeepingUnit.name, _Reader.name(), Frame.name, _LazyDescr.name, _SixMetaPathImporter.name, and Encoding.name.

Here is the call graph for this function:

◆ as_dict()

Dict[str, str] as_dict (   self)

Definition at line 82 of file link.py.

82 def as_dict(self) -> Dict[str, str]:
83 return {self.name: self.value}
84

References MunitParameterEnum.name, MunitParameter.name, MunitTest.name, MunitArgument_.name, Command.name, ConfigOptionParser.name, TransformedHit.name, _PackageInfo.name, InvalidWheel.name, BaseEntryPoint.name(), BasePath.name(), EntryPoint.name, InstallationCandidate.name, VcsInfo.name, ArchiveInfo.name, DirInfo.name, LinkHash.name, Wheel.name, LazyZipOverHTTP.name(), FrozenRequirement.name, InstallationResult.name, InstallRequirement.name(), InstallRequirement.name, Requirement.name(), Candidate.name(), _InstallRequirementBackedCandidate.name(), _InstallRequirementBackedCandidate.name, AlreadyInstalledCandidate.name, AlreadyInstalledCandidate.name(), ExtrasCandidate.name(), RequiresPythonCandidate.name(), ExplicitRequirement.name(), SpecifierRequirement.name(), RequiresPythonRequirement.name(), UnsatisfiableRequirement.name(), Bazaar.name, Mercurial.name, Subversion.name, VcsSupport.name, VersionControl.name, CodingStateMachineDict.name, Language.name, _Cache.name, Distribution.name, InstalledDistribution.name, EggInfoDistribution.name, LegacyMetadata.name, Metadata.name, ResourceBase.name, ExportEntry.name, Matcher.name, LinuxDistribution.name(), Formatter.name, BBCodeFormatter.name, GroffFormatter.name, HtmlFormatter.name, ImageFormatter.name, GifImageFormatter.name, JpgImageFormatter.name, BmpImageFormatter.name, IRCFormatter.name, LatexFormatter.name, NullFormatter.name, RawTokenFormatter.name, TestcaseFormatter.name, PangoMarkupFormatter.name, RtfFormatter.name, SvgFormatter.name, TerminalFormatter.name, Terminal256Formatter.name, TerminalTrueColorFormatter.name, Lexer.name, PythonLexer.name, Python2Lexer.name, _PythonConsoleLexerBase.name, PythonConsoleLexer.name, PythonTracebackLexer.name, Python2TracebackLexer.name, CythonLexer.name, DgLexer.name, NumPyLexer.name, ParserElement.name(), EditablePartial.name(), ElementState.name, LookupDict.name, Color.name, Emoji.name, Splitter.name, RowSplitter.name, ColumnSplitter.name, Layout.name, Tag.name, StockKeepingUnit.name, _Reader.name(), Frame.name, _LazyDescr.name, _SixMetaPathImporter.name, Encoding.name, MunitParameter.value, BaseEntryPoint.value(), EntryPoint.value, LinkHash.value, ExportEntry.value(), Node.value, and Inspect.value.

Here is the call graph for this function:

◆ as_hashes()

Hashes as_hashes (   self)
Return a Hashes instance which checks only for the current hash.

Definition at line 85 of file link.py.

85 def as_hashes(self) -> Hashes:
86 """Return a Hashes instance which checks only for the current hash."""
87 return Hashes({self.name: [self.value]})
88

References MunitParameterEnum.name, MunitParameter.name, MunitTest.name, MunitArgument_.name, Command.name, ConfigOptionParser.name, TransformedHit.name, _PackageInfo.name, InvalidWheel.name, BaseEntryPoint.name(), BasePath.name(), EntryPoint.name, InstallationCandidate.name, VcsInfo.name, ArchiveInfo.name, DirInfo.name, LinkHash.name, Wheel.name, LazyZipOverHTTP.name(), FrozenRequirement.name, InstallationResult.name, InstallRequirement.name(), InstallRequirement.name, Requirement.name(), Candidate.name(), _InstallRequirementBackedCandidate.name(), _InstallRequirementBackedCandidate.name, AlreadyInstalledCandidate.name, AlreadyInstalledCandidate.name(), ExtrasCandidate.name(), RequiresPythonCandidate.name(), ExplicitRequirement.name(), SpecifierRequirement.name(), RequiresPythonRequirement.name(), UnsatisfiableRequirement.name(), Bazaar.name, Mercurial.name, Subversion.name, VcsSupport.name, VersionControl.name, CodingStateMachineDict.name, Language.name, _Cache.name, Distribution.name, InstalledDistribution.name, EggInfoDistribution.name, LegacyMetadata.name, Metadata.name, ResourceBase.name, ExportEntry.name, Matcher.name, LinuxDistribution.name(), Formatter.name, BBCodeFormatter.name, GroffFormatter.name, HtmlFormatter.name, ImageFormatter.name, GifImageFormatter.name, JpgImageFormatter.name, BmpImageFormatter.name, IRCFormatter.name, LatexFormatter.name, NullFormatter.name, RawTokenFormatter.name, TestcaseFormatter.name, PangoMarkupFormatter.name, RtfFormatter.name, SvgFormatter.name, TerminalFormatter.name, Terminal256Formatter.name, TerminalTrueColorFormatter.name, Lexer.name, PythonLexer.name, Python2Lexer.name, _PythonConsoleLexerBase.name, PythonConsoleLexer.name, PythonTracebackLexer.name, Python2TracebackLexer.name, CythonLexer.name, DgLexer.name, NumPyLexer.name, ParserElement.name(), EditablePartial.name(), ElementState.name, LookupDict.name, Color.name, Emoji.name, Splitter.name, RowSplitter.name, ColumnSplitter.name, Layout.name, Tag.name, StockKeepingUnit.name, _Reader.name(), Frame.name, _LazyDescr.name, _SixMetaPathImporter.name, Encoding.name, MunitParameter.value, BaseEntryPoint.value(), EntryPoint.value, LinkHash.value, ExportEntry.value(), Node.value, and Inspect.value.

Here is the call graph for this function:

◆ find_hash_url_fragment()

Optional["LinkHash"] find_hash_url_fragment (   cls,
str  url 
)
Search a string for a checksum algorithm name and encoded output value.

Definition at line 74 of file link.py.

74 def find_hash_url_fragment(cls, url: str) -> Optional["LinkHash"]:
75 """Search a string for a checksum algorithm name and encoded output value."""
76 match = cls._hash_url_fragment_re.search(url)
77 if match is None:
78 return None
79 name, value = match.groups()
80 return cls(name=name, value=value)
81
for i

References LinkHash._hash_url_fragment_re, and i.

◆ is_hash_allowed()

bool is_hash_allowed (   self,
Optional[Hashes hashes 
)
Return True if the current hash is allowed by `hashes`.

Definition at line 89 of file link.py.

89 def is_hash_allowed(self, hashes: Optional[Hashes]) -> bool:
90 """
91 Return True if the current hash is allowed by `hashes`.
92 """
93 if hashes is None:
94 return False
95 return hashes.is_hash_allowed(self.name, hex_digest=self.value)
96
97
98@dataclass(frozen=True)

Referenced by Hashes.has_one_of().

Here is the caller graph for this function:

Field Documentation

◆ _hash_url_fragment_re

_hash_url_fragment_re
staticprotected
Initial value:
# NB: we do not validate that the second group (.*) is a valid hex
# digest. Instead, we simply keep that string in this class, and then check it
# against Hashes when hash-checking is needed. This is easier to debug than
# proactively discarding an invalid hex digest, as we handle incorrect hashes
# and malformed hashes in the same place.
r"[#&]({choices})=([^&]*)".format(
choices="|".join(re.escape(hash_name) for hash_name in _SUPPORTED_HASHES)
),
)

Definition at line 58 of file link.py.

Referenced by LinkHash.find_hash_url_fragment().

◆ name [1/2]

str name
static

Definition at line 55 of file link.py.

Referenced by AlreadyInstalledCandidate.__eq__(), Distribution.__eq__(), ExportEntry.__eq__(), _LazyDescr.__get__(), Distribution.__hash__(), ElementState.__init__(), Requirement.__init__(), LinkHash.__post_init__(), InstallationCandidate.__repr__(), Distribution.__repr__(), Metadata.__repr__(), ExportEntry.__repr__(), Encoding.__repr__(), Color.__rich_repr__(), Layout.__rich_repr__(), InstallationCandidate.__str__(), InstalledDistribution.__str__(), EggInfoDistribution.__str__(), Requirement.__str__(), ParserElement.__str__(), Tag.__str__(), _SixMetaPathImporter._add_module(), Matcher._check_compatible(), InstallRequirement._get_archive_name(), Wheel._get_extensions(), _SixMetaPathImporter._get_module(), ConfigOptionParser._get_ordered_configuration_items(), Distribution._get_requirements(), _Cache.add(), InstallRequirement.archive(), LinkHash.as_dict(), LinkHash.as_hashes(), Wheel.build(), _Cache.clear(), Wheel.filename(), Layout.get(), InstallRequirement.get_dist(), InstalledDistribution.get_distinfo_file(), RequirementCommand.get_requirements(), Wheel.get_wheel_metadata(), InstallRequirement.install(), Wheel.install(), SpecifierRequirement.is_satisfied_by(), LinuxDistribution.linux_distribution(), Wheel.metadata(), Distribution.name_and_version(), InstallRequirement.prepare_metadata(), Distribution.provides(), Metadata.provides(), VcsSupport.register(), VersionControl.run_command(), InstallRequirement.uninstall(), Wheel.update(), and Wheel.verify().

◆ name [2/2]

name

Definition at line 95 of file link.py.

Referenced by AlreadyInstalledCandidate.__eq__(), Distribution.__eq__(), ExportEntry.__eq__(), _LazyDescr.__get__(), Distribution.__hash__(), ElementState.__init__(), Requirement.__init__(), LinkHash.__post_init__(), InstallationCandidate.__repr__(), Distribution.__repr__(), Metadata.__repr__(), ExportEntry.__repr__(), Encoding.__repr__(), Color.__rich_repr__(), Layout.__rich_repr__(), InstallationCandidate.__str__(), InstalledDistribution.__str__(), EggInfoDistribution.__str__(), Requirement.__str__(), ParserElement.__str__(), Tag.__str__(), _SixMetaPathImporter._add_module(), Matcher._check_compatible(), InstallRequirement._get_archive_name(), Wheel._get_extensions(), _SixMetaPathImporter._get_module(), ConfigOptionParser._get_ordered_configuration_items(), Distribution._get_requirements(), _Cache.add(), InstallRequirement.archive(), LinkHash.as_dict(), LinkHash.as_hashes(), Wheel.build(), _Cache.clear(), Wheel.filename(), Layout.get(), InstallRequirement.get_dist(), InstalledDistribution.get_distinfo_file(), RequirementCommand.get_requirements(), Wheel.get_wheel_metadata(), InstallRequirement.install(), Wheel.install(), SpecifierRequirement.is_satisfied_by(), LinuxDistribution.linux_distribution(), Wheel.metadata(), Distribution.name_and_version(), InstallRequirement.prepare_metadata(), Distribution.provides(), Metadata.provides(), VcsSupport.register(), VersionControl.run_command(), InstallRequirement.uninstall(), Wheel.update(), and Wheel.verify().

◆ value

str value
static

Definition at line 56 of file link.py.

Referenced by Node.__str__(), Inspect._render(), LinkHash.as_dict(), and LinkHash.as_hashes().


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