def _sort_key(self):
"""Return a key for sorting SemanticVersion's on."""
# key things:
# - final is after rc's, so we make that a/b/rc/z
# - dev==None is after all other devs, so we use sys.maxsize there.
# - unqualified dev releases come before any pre-releases.
# So we do:
# (major, minor, patch) - gets the major grouping.
# (0|1) unqualified dev flag
# (a/b/rc/z) - release segment grouping
# pre-release level
# dev count, maxsize for releases.
rc_lookup = {'a': 'a', 'b': 'b', 'rc': 'rc', None: 'z'}
if self._dev_count and not self._prerelease_type:
uq_dev = 0
else:
uq_dev = 1
return (
self._major, self._minor, self._patch,
uq_dev,
rc_lookup[self._prerelease_type], self._prerelease,
self._dev_count or sys.maxsize)
评论列表
文章目录