MCPcopy Create free account
hub / github.com/numpy/numpy / _legacy_cmpkey

Function _legacy_cmpkey

numpy/_utils/_pep440.py:224–248  ·  view source on GitHub ↗
(version)

Source from the content-addressed store, hash-verified

222
223
224def _legacy_cmpkey(version):
225 # We hardcode an epoch of -1 here. A PEP 440 version can only have an epoch
226 # greater than or equal to 0. This will effectively put the LegacyVersion,
227 # which uses the defacto standard originally implemented by setuptools,
228 # as before all PEP 440 versions.
229 epoch = -1
230
231 # This scheme is taken from pkg_resources.parse_version setuptools prior to
232 # its adoption of the packaging library.
233 parts = []
234 for part in _parse_version_parts(version.lower()):
235 if part.startswith("*"):
236 # remove "-" before a prerelease tag
237 if part < "*final":
238 while parts and parts[-1] == "*final-":
239 parts.pop()
240
241 # remove trailing zeros from each series of numeric parts
242 while parts and parts[-1] == "00000000":
243 parts.pop()
244
245 parts.append(part)
246 parts = tuple(parts)
247
248 return epoch, parts
249
250
251# Deliberately not anchored to the start and end of the string, to make it

Callers 1

__init__Method · 0.85

Calls 3

_parse_version_partsFunction · 0.85
lowerMethod · 0.80
startswithMethod · 0.80

Tested by

no test coverage detected