MCPcopy Create free account
hub / github.com/aboutcode-org/vulnerablecode / VersionedPackage

Class VersionedPackage

vulnerabilities/utils.py:137–154  ·  view source on GitHub ↗

A PackageURL with a Version class. This class is used to get around bisect module's lack of supplying custom comparator. Get rid of this once we use python 3.10 which supports this. See https://github.com/python/cpython/pull/20556

Source from the content-addressed store, hash-verified

135
136@total_ordering
137class VersionedPackage:
138 """
139 A PackageURL with a Version class.
140 This class is used to get around bisect module's lack of supplying custom
141 comparator. Get rid of this once we use python 3.10 which supports this.
142 See https://github.com/python/cpython/pull/20556
143 """
144
145 def __init__(self, purl: PackageURL):
146 self.purl = purl
147 vrc = RANGE_CLASS_BY_SCHEMES.get(purl.type)
148 self.version = vrc.version_class(purl.version)
149
150 def __eq__(self, other):
151 return self.version == other.version
152
153 def __lt__(self, other):
154 return self.version < other.version
155
156
157def update_purl_version(purl, version):

Callers 1

nearest_patched_packageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected