pygplates.Version¶
-
class
pygplates.
Version
¶ Bases:
Boost.Python.instance
A version of pyGPlates (GPlates Python API).
All comparison operators (==, !=, <, <=, >, >=) are supported and Version is hashable (can be used as a key in a
dict
).During the lifespan of pyGPlates, theimported pyGPlates version
has been incremented for each API change. So it can be used to ensure new API additions are present in the imported pyGPlates library.For example, if we are using a new API function that was added in this revision (which is 28) then we can ensure we are using a sufficient API version by checking this at the beginning of our script:if pygplates.Version.get_imported_version() < pygplates.Version(28): print 'PyGPlates version %s is not supported' % pygplates.Version.get_imported_version()
To print the version string of the imported pyGPlates library:
print 'imported pyGPlates version: %s' % pygplates.Version.get_imported_version()
…which for pyGPlates revision 28 (associated with GPlates version 2.2.0) will print
28 (GPlates 2.2.0)
. However, note that the associated GPlates version is only printed when usingget_imported_version()
. So the following example only prints the revision number28
:print 'PyGPlates version: %s' % pygplates.Version(28)
There is also a
pygplates.__version__
string equal to the concatenation of the GPlates version and the pyGPlates revision of the imported pyGPlates library. For pyGPlates revision 28 (associated with GPlates version 2.2.0) this would be'2.2.0.28'
.-
__init__
(revision)¶ Create a Version instance from a revision number.
Parameters: revision (int) – the revision number To check if the imported pyGPlates library is revision 28 or greater:
if pygplates.Version.get_imported_version() < pygplates.Version(28): print 'PyGPlates version %s is not supported' % pygplates.Version.get_imported_version()
Methods
__init__
(revision)Create a Version instance from a revision number. get_imported_version
()[staticmethod] Return the version of the imported pyGPlates library. get_revision
()Returns the integer revision number. -
static
get_imported_version
()¶ [staticmethod] Return the version of the imported pyGPlates library.
Returns: a Version instance representing the revision number
of the imported pyGPlates libraryReturn type: Version
To check if the imported pyGPlates library is revision 28 or greater:
if pygplates.Version.get_imported_version() < pygplates.Version(28): print 'PyGPlates version %s is not supported' % pygplates.Version.get_imported_version()
-
get_revision
()¶ Returns the integer revision number.
Return type: int
-