-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updated README.md * Add pytest tests and GitHub Actions workflow * Add pytest tests and GitHub Actions workflow * Add pytest tests and GitHub Actions workflow * Added the Check version Capability * added version.py
- Loading branch information
1 parent
044f37b
commit 2c8b96f
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
# version.py | ||
|
||
import importlib.metadata | ||
|
||
def get_latest_release_version(package_name): | ||
""" | ||
Get the latest released version of a Python package. | ||
Args: | ||
package_name (str): The name of the Python package. | ||
Returns: | ||
str: The latest released version or '0.0.0' if not found. | ||
""" | ||
try: | ||
distribution = importlib.metadata.distribution(package_name) | ||
return distribution.version | ||
except importlib.metadata.PackageNotFoundError: | ||
return '0.0.0' | ||
|
||
def get_Version(current_version): | ||
""" | ||
Check if there is a newer version of the package available. | ||
Args: | ||
current_version (str): The current version of the package. | ||
Returns: | ||
None: Prints a message indicating if a newer version is available. | ||
""" | ||
package_name = 'checkversions' | ||
latest_version = get_latest_release_version(package_name) | ||
|
||
if latest_version > current_version: | ||
print(f"A newer version ({latest_version}) of checkversions is available.") | ||
else: | ||
pass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters