MCPcopy Index your code
hub / github.com/apache/cassandra-python-driver / Version

Class Version

cassandra/util.py:1698–1782  ·  view source on GitHub ↗

Representation of a Cassandra version. Mostly follows the implementation of the same logic in the Java driver; see https://github.com/apache/cassandra-java-driver/blob/4.19.2/core/src/main/java/com/datastax/oss/driver/api/core/Version.java. Cassandra versions are assumed to correspond

Source from the content-addressed store, hash-verified

1696
1697@total_ordering
1698class Version(object):
1699 """
1700 Representation of a Cassandra version. Mostly follows the implementation of the same logic in the Java driver;
1701 see https://github.com/apache/cassandra-java-driver/blob/4.19.2/core/src/main/java/com/datastax/oss/driver/api/core/Version.java.
1702
1703 Cassandra versions are assumed to correspond to major.minor.patch with an optional additional numeric build field as well as a
1704 string prerelease field.
1705 """
1706
1707 def __init__(self, version):
1708 self._version = version
1709
1710 match = VERSION_REGEX.match(version)
1711 if not match:
1712 raise ValueError("Version string {0} did not match expected format".format(version))
1713
1714 self.major = int(match[1])
1715 self.minor = int(match[2])
1716
1717 try:
1718 self.patch = self._cleanup_int(match[3])
1719 except:
1720 self.patch = 0
1721
1722 try:
1723 self.build = self._cleanup_int(match[4])
1724 except:
1725 self.build = 0
1726
1727 try:
1728 self.prerelease = self._cleanup_str(match[5])
1729 except:
1730 self.prerelease = ""
1731
1732 # This is used in a few places below so let's just build it now
1733 self._tuple = (self.major, self.minor, self.patch, self.build, self.prerelease)
1734
1735 # Trim off the leading '.' characters and convert the discovered value to an integer
1736 def _cleanup_int(self, instr):
1737 return int(instr[1:]) if instr else 0
1738
1739 # Trim off the leading '.' or '~' characters and just return the string directly
1740 def _cleanup_str(self, instr):
1741 return instr[1:] if instr else ""
1742
1743 def __hash__(self):
1744 return hash(self._tuple)
1745
1746 def __repr__(self):
1747 version_string = "Version({0}, {1}, {2}".format(self.major, self.minor, self.patch)
1748 if self.build:
1749 version_string += ", {}".format(self.build)
1750 if self.prerelease:
1751 version_string += ", {}".format(self.prerelease)
1752 version_string += ")"
1753
1754 return version_string
1755

Callers 15

test_version_parsingMethod · 0.90
test_version_compareMethod · 0.90
cluster.pyFile · 0.90
ControlConnectionClass · 0.90
_get_peers_queryMethod · 0.90
get_schema_parserFunction · 0.90
util.pyFile · 0.90
__init__.pyFile · 0.85

Calls

no outgoing calls

Tested by 15

test_version_parsingMethod · 0.72
test_version_compareMethod · 0.72
test_dse_5xMethod · 0.68
test_dse_60Method · 0.68
test_dse_67Method · 0.68
setup_moduleFunction · 0.68
setup_moduleFunction · 0.68
test_host_addressesMethod · 0.68