Represents a version number that can be parsed and compared.
Project description
Version Class
Represents a version number. This class cannot be extended. Sealed Class
Installation
You can install the Version Class from PyPI:
pip install verr
Constructors
Name | Description | |
---|---|---|
Version() | Initializes a new instance of the Version class. | |
Version(ver_str) | Initializes a new instance of the Version class using the specified string to be parsed | |
Version(version) | Initializes a new instance of the Version class using the specified version. | |
Version(major, minor) | Initializes a new instance of the Version class using the specified major and minor values. | |
Version(major, minor, build) | Initializes a new instance of the Version class using the specified major, minor, and build values. | |
Version(major, minor, build, revision) | Initializes a new instance of the Version class with the specified major, minor, build, and revision numbers. |
Properties
Name | Description | |
---|---|---|
major | Gets the value of the major component of the version number for the current Version object. | |
minor | Gets the value of the minor component of the version number for the current Version object. | |
build | Initializes a new instance of the Version class using the specified major and minor values. | |
revision | Gets the value of the revision component of the version number for the current Version object. | |
major_revision | Gets the high 16 bits of the revision number. | |
minor_revision | Gets the low 16 bits of the revision number. |
Methods
Name | Description | |
---|---|---|
parse(input) | Converts the string representation of a version number to an equivalent Version object. Raises errors if input has issues. | |
try_parse(input) | Converts the string representation of a version number to an equivalent Version object. Does not raise errors. | |
to_str() | Converts the value of the current Version object to its equivalent String representation. | |
to_str(field_count) | Converts the value of the current Version object to its equivalent String representation. A specified count indicates the number of components to return. |
Usage
from verr import Version
v = Version(1, 2, 3, 4)
print(v.major) # 1
print(v.minor) # 2
print(v.build) # 3
print(v.revision) # 4
print(v) # 1.2.3.4
v = Version.parse("1.2.3")
print(v.major) # 1
print(v.minor) # 2
print(v.build) # 3
v1 = Version.parse("1.2.2")
v2 = Version.parse("1.2.3")
print(v1 > v2) # False
print(v1 <= v2) # True
v = Version(1,2,3, int("ffbbff0b", 16))
print(v.major_revision == int("ffbb", 16)) # True
print(v.minor_revision == int("ff0b", 16)) # True
print(v) # 1.2.3.4290510603
print(v.to_str(3)) # 1.2.3
v_result = Version.try_parse("22.3")
if v_result[0] == True:
v = v_result[1]
print(v) # 22.3
else:
err = v_result[1]
print(e)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
verr-0.1.2.tar.gz
(9.3 kB
view hashes)
Built Distribution
verr-0.1.2-py3-none-any.whl
(7.1 kB
view hashes)