Package: abstract-security
Abstract SecurityTheabstract_securitymodule is a Python utility that provides functionality for managing environment variables and securely loading sensitive information from.envfiles. It is designed to simplify the process of accessing and managing environment variables within your Python applications.Table of ContentsFeaturesInstallationUsageFunctionsLicenseContactFeaturesFlexible.envFile Location: Searches for.envfiles in current working directory, home directory, and a special.envy_alldirectory within the home directory.Clean and Secure Key Retrieval: Offers functionality to cleanly split strings at equals signs and safely retrieve environment variable values.InstallationInstallabstract_securityusing pip:pipinstallabstract-securityUsageBasic UsageHere's a simple example to get started:fromabstract_securityimportget_env_valueenv_key='YOUR_ENV_VARIABLE_KEY'value=get_env_value(key=env_key)Advanced UsageTheAbstractEnvclass can be used for more advanced scenarios, including custom paths and file names for the.envfile.fromabstract_securityimportAbstractEnv# Initialize with custom parametersabstract_env=AbstractEnv(key='YOUR_ENV_VARIABLE_KEY',file_name='custom.env',path='/custom/path')value=abstract_env.env_value##FunctionsAbstractEnvClassTheAbstractEnvclass allows you to manage environment variables and securely load values from a.envfile. Here's how to use it:Initializing anAbstractEnvObject# Create an AbstractEnv object with default settingsabstract_env=AbstractEnv()You can also customize the initialization by specifying the key, file name, and path as follows:# Custom initializationabstract_env=AbstractEnv(key='MY_PASSWORD',file_name='.env',path='/path/to/.env')Getting Environment Variable ValuesYou can retrieve the value of a specific environment variable using theget_env_valuemethod of theAbstractEnvobject:# Retrieve the value of a specific environment variablevalue=abstract_env.get_env_value(key='YOUR_ENV_VARIABLE')get_env_valueFunctionAlternatively, you can use theget_env_valuefunction to directly retrieve the value of an environment variable without creating anAbstractEnvobject:fromabstract_securityimportget_env_value# Retrieve the value of a specific environment variablevalue=get_env_value(key='YOUR_ENV_VARIABLE',path='/path/to/.env')API ReferenceAbstractEnvClassAbstractEnv(key='MY_PASSWORD', file_name='.env', path=os.getcwd())Initializes anAbstractEnvobject to manage environment variables.key(str, optional): The key to search for in the.envfile. Defaults to 'MY_PASSWORD'.file_name(str, optional): The name of the.envfile. Defaults to '.env'.path(str, optional): The path where the.envfile is located. Defaults to the current working directory.re_initialize(key='MY_PASSWORD', file_name='.env', path=os.getcwd())Re-initializes anAbstractEnvobject with new settings.key(str, optional): The key to search for in the.envfile. Defaults to 'MY_PASSWORD'.file_name(str, optional): The name of the.envfile. Defaults to '.env'.path(str, optional): The path where the.envfile is located. Defaults to the current working directory.get_env_value(key='MY_PASSWORD', path=os.getcwd(), file_name='.env')Retrieves the value of the specified environment variable.key(str): The key to search for in the.envfile.path(str): The path to the environment file.file_name(str): The name of the environment file.get_env_valueFunctionget_env_value(key=None, path=None, file_name=None)Retrieves the value of a specified environment variable from a.envfile.key(str, optional): The key to search for in the.envfile. Defaults to None.path(str, optional): The path to the.envfile. Defaults to None.file_name(str, optional): The name of the.envfile. Defaults to None.LicenseThis module is distributed under theMIT License.For more information and usage examples, please refer to theGitHub repositoryandPyPI package.If you encounter any issues or have questions, feel free to open an issue on GitHub or contact the author, putkoff, for assistance.ContactAuthor: putkoffEmail:partners@abstractendeavors.comProject Link:https://github.com/AbstractEndeavors/abstract_security