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

Class Version

numpy/_utils/_pep440.py:285–389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283
284
285class Version(_BaseVersion):
286
287 _regex = re.compile(
288 r"^\s*" + VERSION_PATTERN + r"\s*$",
289 re.VERBOSE | re.IGNORECASE,
290 )
291
292 def __init__(self, version):
293 # Validate the version and parse it into pieces
294 match = self._regex.search(version)
295 if not match:
296 raise InvalidVersion("Invalid version: '{0}'".format(version))
297
298 # Store the parsed out pieces of the version
299 self._version = _Version(
300 epoch=int(match.group("epoch")) if match.group("epoch") else 0,
301 release=tuple(int(i) for i in match.group("release").split(".")),
302 pre=_parse_letter_version(
303 match.group("pre_l"),
304 match.group("pre_n"),
305 ),
306 post=_parse_letter_version(
307 match.group("post_l"),
308 match.group("post_n1") or match.group("post_n2"),
309 ),
310 dev=_parse_letter_version(
311 match.group("dev_l"),
312 match.group("dev_n"),
313 ),
314 local=_parse_local_version(match.group("local")),
315 )
316
317 # Generate a key which will be used for sorting
318 self._key = _cmpkey(
319 self._version.epoch,
320 self._version.release,
321 self._version.pre,
322 self._version.post,
323 self._version.dev,
324 self._version.local,
325 )
326
327 def __repr__(self):
328 return "<Version({0})>".format(repr(str(self)))
329
330 def __str__(self):
331 parts = []
332
333 # Epoch
334 if self._version.epoch != 0:
335 parts.append("{0}!".format(self._version.epoch))
336
337 # Release segment
338 parts.append(".".join(str(x) for x in self._version.release))
339
340 # Pre-release
341 if self._version.pre is not None:
342 parts.append("".join(str(x) for x in self._version.pre))

Callers 1

parseFunction · 0.85

Calls 1

compileMethod · 0.45

Tested by

no test coverage detected