The DialogBackendVersion
class¶
- class dialog.DialogBackendVersion(dotted_part_or_str, rest='')[source]¶
Bases:
dialog.BackendVersion
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'-20130902'
.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 thefromstring()
class method. This is particularly useful with the result ofd.backend_version()
, where d is aDialog
instance. Actually, the main constructor detects if its first argument is a string and callsfromstring()
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
DialogBackendVersion
instance,str(bv)
is a string representing the same version (for instance,"1.2-20130902"
).Two
DialogBackendVersion
instances can be compared with the usual comparison operators (<
,<=
,==
,!=
,>=
,>
). The algorithm is designed so that the following order is respected (after instanciation withfromstring()
):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.
- classmethod fromstring(s)[source]¶
Create a
DialogBackendVersion
instance from a dialog version string.- Parameters
s (str) – a dialog version string
- Returns
a
DialogBackendVersion
instance representing the same string
Notable exceptions: