apikeyper.utils package
Submodules
apikeyper.utils.decorators module
decorators.py
Author: tayja Date: 8/3/2023
This module provides decorators for ensuring API keys are available for specific services. It offers both function-level and class-level decorators:
- apikey_required(service_names):
A decorator for functions. When a function decorated with this is called, it checks if the required API keys are available. If a key is not found in the database, it prompts the user for input and saves the provided key.
- Args:
- service_names (Union[str, List[str]]):
A list of service names for which API keys are needed. If a single string is provided, it’s converted to a list.
- apikey_required_class(service_names):
A decorator for classes. When an instance of a class decorated with this is created, it checks if the required API keys are available for the given services. If a key is not found in the database, it prompts the user for input and saves the provided key. It then sets the API key as a class attribute.
- Args:
- service_names (Union[str, List[str]]):
A list of service names for which API keys are needed. If a single string is provided, it’s converted to a list.
Usage example:
@apikey_required(["service1", "service2"])
def my_function():
pass
@apikey_required_class(["service1", "service2"])
class MyClass:
pass
Note
This module uses the APIKeyPER database manager for retrieving and storing API keys.Ensure that the APIKeyPER manager is initialized and connected to the correct database before use.
Module contents
__init__.py
Author: Taylor-Jayde Date: 8/3/2023
This module provides the PackageChecker class to verify the installation status of a list of Python packages within the current environment.
The main functionality of the PackageChecker class is to take a list of package names as input and return a dictionary indicating which packages are installed and which are not.
Usage example:
checker = PackageChecker(["numpy", "tensorflow"])
status = checker.check_installed_packages()
print(status) # Output might be: {"numpy": True, "tensorflow": False}
- Dependencies:
This module requires the pkg_resources module to determine the installation status of packages.
Note
Ensure the list of packages provided to the PackageChecker class are correctly named as they appear in the Python Package Index (PyPI) or your local installation.