Core FunctionsΒΆ
VCheck provides several functions for quickly checking the version of a given module:
check_raise(mod[, hexsha, version, verbose]) |
Raises an error if a given Python module does not match a particular git sha1 signature or version. |
check_warn(mod[, hexsha, version, verbose]) |
Warns if a given Python module does not match a particular git sha1 signature or version. |
vcheck(mod[, hexsha, version]) |
Checks a given module against either a git sha1 signature or a version. |
version(mod) |
Returns the version information for a given module if possible. |
hexsha(mod) |
Returns the hexsha information for a given module if possible. |
It is possible to raise an error with check_raise, a warning
with check_warn, or to obtain a boolean with vcheck:
Example
Version-checking VCheck:
>>> if vcheck.vcheck(vcheck, version='0'): print('Not version 0')
Not version 0
>>> vcheck.check_warn(vcheck, version='0')
__main__:1: UserWarning: VersionError: Repo for module vcheck is dirty (changes have been made); version not well-defined.
>>> vcheck.check_raise(vcheck, version='0')
Traceback (most recent call last):
...
vcheck.versionerror.VersionError: Repo for module vcheck is dirty (changes have been made); version not well-defined.
It is also possible to print the version or hexsha of a module, which may be quicker than finding the version or hexsha another way:
Example
Checking the version and hexsha of VCheck:
>>> vcheck.version(vcheck)
'v1.3.1'
>>> vcheck.hexsha(vcheck)
'5b6fb754f72d4ed9dc6191c43aeb7776e93dd456'