Class representing possible versions of the dialog backend.
The purpose of this class is to make it easy to reliably compare between versions of the dialog backend. It encapsulates the specific details of the backend versioning scheme to allow eventual adaptations to changes in this scheme without affecting external code.
The version is represented by two components in this class: the dotted part and the rest. For instance, in the
'1.2'version string, the dotted part is
[1, 2]and the rest is the empty string. However, in version
'1.2-20130902', the dotted part is still
[1, 2], but the rest is the string
Instances of this class can be created with the constructor by specifying the dotted part and the rest. Alternatively, an instance can be created from the corresponding version string (e.g.,
'1.2-20130902') using the
fromstring()class method. This is particularly useful with the result of
d.backend_version(), where d is a
Dialoginstance. Actually, the main constructor detects if its first argument is a string and calls
fromstring()in this case as a convenience. Therefore, all of the following expressions are valid to create a DialogBackendVersion instance:
DialogBackendVersion([1, 2]) DialogBackendVersion([1, 2], "-20130902") DialogBackendVersion("1.2-20130902") DialogBackendVersion.fromstring("1.2-20130902")
If bv is a
str(bv)is a string representing the same version (for instance,
DialogBackendVersioninstances can be compared with the usual comparison operators (
>). The algorithm is designed so that the following order is respected (after instanciation with
1.2 < 1.2-20130902 < 1.2-20130903 < 1.2.0 < 1.2.0-20130902
among other cases. Actually, the dotted parts are the primary keys when comparing and rest strings act as secondary keys. Dotted parts are compared with the standard Python list comparison and rest strings using the standard Python string comparison.