Created
February 24, 2019 13:24
-
-
Save dkdndes/673950b62a8dd50a229d0f9c94ef6d11 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| """This file checks, if the package is installed on the current system.""" | |
| import os | |
| import sys | |
| import argparse | |
| from importlib import import_module | |
| def main(): | |
| """ | |
| Check if the package name is installed. | |
| Returns true, if the package is installed, otherwise false. | |
| """ | |
| try: | |
| # Parse the argument as project name | |
| desc_string = "Check if the python package is installed." | |
| parser = argparse.ArgumentParser(description=desc_string) | |
| parser.add_argument('package_name', action="store", type=str) | |
| package_name = parser.parse_args().package_name | |
| import_module(package_name) | |
| print('true') | |
| except ImportError: | |
| print('false') | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment