version
— Determine Pywikibot Version#
Module to determine the pywikibot version (tag, revision and date).
- version.get_module_filename(module)[source]#
Retrieve filename from an imported pywikibot module.
It uses the __file__ attribute of the module. If it’s file extension ends with py and another character the last character is discarded when the py file exist.
- Parameters:
module (module) – The module instance.
- Returns:
The filename if it’s a pywikibot module otherwise None.
- Return type:
Optional[str]
- version.get_module_mtime(module)[source]#
Retrieve the modification time from an imported module.
- Parameters:
module (module) – The module instance.
- Returns:
The modification time if it’s a pywikibot module otherwise None.
- Return type:
datetime or None
- version.get_toolforge_hostname()[source]#
Get hostname of the current Toolforge host.
New in version 3.0.
- Returns:
The hostname of the currently running host, if it is in Wikimedia Toolforge; otherwise return None.
- Return type:
Optional[str]
- version.getversion(online=True)[source]#
Return a pywikibot version string.
- Parameters:
online (bool) – Include information obtained online
- Return type:
str
- version.getversion_git(path=None)[source]#
Get version info for a Git clone.
- Parameters:
path – directory of the Git checkout
- Returns:
tag (name for the repository),
rev (current revision identifier),
date (date of current revision),
hash (git hash for the current revision)
- Return type:
tuple
of threestr
and atime.struct_time
- version.getversion_nightly(path=None)[source]#
Get version info for a nightly release.
- Parameters:
path – directory of the uncompressed nightly.
- Returns:
tag (name for the repository),
rev (current revision identifier),
date (date of current revision),
hash (git hash for the current revision)
- Return type:
tuple
of threestr
and atime.struct_time
- version.getversion_onlinerepo(path='branches/master')[source]#
Retrieve current framework git hash from Gerrit.
- Parameters:
path (str) –
- version.getversion_package(path=None)[source]#
Get version info for an installed package.
- Parameters:
path – Unused argument
- Returns:
tag: ‘pywikibot/__init__.py’
rev: ‘-1 (unknown)’
date (date the package was installed locally),
hash (git hash for the current revision of ‘pywikibot/__init__.py’)
- Return type:
Tuple[str, str, str, str]
- version.getversion_svn(path=None)[source]#
Get version info for a Subversion checkout.
- Parameters:
path – directory of the Subversion checkout
- Returns:
tag (name for the repository),
rev (current Subversion revision identifier),
date (date of current revision),
hash (git hash for the Subversion revision)
- Return type:
tuple
of threestr
and atime.struct_time
- version.getversiondict()[source]#
Get version info for the package.
- Returns:
tag (name for the repository),
rev (current revision identifier),
date (date of current revision),
hash (git hash for the current revision)
- Return type:
Dict[str, str]
- version.github_svn_rev2hash(tag, rev)[source]#
Convert a Subversion revision to a Git hash using GitHub.
- Parameters:
tag (str) – name of the Subversion repo on GitHub
rev – Subversion revision identifier
- Returns:
the git hash
- version.package_versions(modules=None, builtins=False, standard_lib=None)[source]#
Retrieve package version information.
When builtins or standard_lib are None, they will be included only if a version was found in the package.
- Parameters:
modules (Optional[List[str]]) – Modules to inspect
builtins (Optional[bool]) – Include builtins
standard_lib (Optional[bool]) – Include standard library packages
- version.svn_rev_info(path)[source]#
Fetch information about the current revision of a Subversion checkout.
- Parameters:
path – directory of the Subversion checkout
- Returns:
tag (name for the repository),
rev (current Subversion revision identifier),
date (date of current revision),
- Return type:
tuple
of twostr
and atime.struct_time