From 5bfc25ff514662182b528a51eb0984f6bd12b958 Mon Sep 17 00:00:00 2001
From: Sebastien Rousseau
+
+
+ Strings module for the encryption_helper package.
+
+ Attributes •
+ Usage •
+ License
+
Strings module for the encryption_helper package.
+
Encryption Helper Python - Strings Module
+
+
+
Encryption Helper Python - Strings Module
+Encryption Helper Python
Strings Module
+
+
+
+
+
+ Context module for the encryption_helper package. +
+ ++ Classes • + Usage • + License +
+ + +## Classes + +The `context.py` module provides a `Context` class for managing application-wide settings and logging. It implements the Singleton pattern to ensure only one instance of the context exists. + +### Context + +A singleton class for managing application context and logging. + +#### Attributes + +- **_instance** (Optional[Context]): The singleton instance of the Context class. +- **name** (str): The name of the application context, used for logging. +- **log_level** (int): The current logging level. +- **logger** (Optional[logging.Logger]): The logger instance for the context. + +### Methods + +- `__new__(cls) -> Context`: Creates and returns the singleton instance of the Context class. +- `get_instance(cls) -> Context`: Gets the singleton instance of the Context class. +- `set_name(self, name: str) -> None`: Sets the name of the context. +- `set_log_level(self, log_level: Optional[str]) -> None`: Sets the logging level for the context. +- `init_logging(self) -> None`: Initializes the logger for the context. +- `get_logger(self) -> logging.Logger`: Gets the logger for the context, initializing it if necessary. + +## Usage + +This module defines a `Context` class for managing application-wide settings and logging. + +### Example + +```python +from encryption_helper.context.context import Context + +# Get the singleton instance of the Context class +context = Context.get_instance() + +# Set the name and logging level of the context +context.set_name('my_app') +context.set_log_level('DEBUG') + +# Get the logger instance and log a message +logger = context.get_logger() +logger.debug('This is a debug message') +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE) file for details. \ No newline at end of file diff --git a/encryption_helper/utils/checks/README.md b/encryption_helper/utils/checks/README.md index e69de29..be5f2cc 100644 --- a/encryption_helper/utils/checks/README.md +++ b/encryption_helper/utils/checks/README.md @@ -0,0 +1,55 @@ + +
+
+
+
+
+ Checks module for the encryption_helper package. +
+ ++ Functions • + Usage • + License +
+ + +## Functions + +The `checks.py` module provides utility functions for input validation. + +### str_none_or_empty + +Check if one or more input strings are `None` or empty. + +#### Args + +- **argv (str)**: A variable number of string arguments to be checked. + +#### Returns + +- **bool**: `True` if any of the input strings is `None` or empty; otherwise `False`. + +#### Examples + +```python +from encryption_helper.utils.checks import str_none_or_empty + +print(str_none_or_empty('test', 'hello', 'world')) # Output: False +print(str_none_or_empty('test', None, 'world')) # Output: True +print(str_none_or_empty('test', '', 'world')) # Output: True +print(str_none_or_empty('test', ' ', 'world')) # Output: True +print(str_none_or_empty()) # Output: False +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../../LICENSE) file for details. diff --git a/encryption_helper/utils/io/README.md b/encryption_helper/utils/io/README.md index e69de29..808ab25 100644 --- a/encryption_helper/utils/io/README.md +++ b/encryption_helper/utils/io/README.md @@ -0,0 +1,122 @@ + +
+
+
+
+
+ I/O modules for the encryption_helper package. +
+ ++ Read File Functions • + Write File Functions • + Usage • + License +
+ + +## Read File Functions + +The `read_file.py` module provides functions for reading text files in binary mode. + +### read_text_in_binary_mode + +Read text from a file in binary mode given a directory and file name. + +#### Args + +- **directory (str)**: The directory where the file is located. +- **file_name (str)**: The name of the file to be read. + +#### Returns + +- **bytes**: The content of the file read in binary mode. + +#### Raises + +- **Exception**: If one or more arguments are empty. +- **OSError**: If there is an error reading the file. + +### read_text_in_binary_mode_abs + +Read text from a file in binary mode given an absolute file path. + +#### Args + +- **absolute_file_path (str)**: The absolute path to the file to be read. + +#### Returns + +- **bytes**: The content of the file read in binary mode. + +#### Raises + +- **Exception**: If one or more arguments are empty. +- **OSError**: If there is an error reading the file. + +## Write File Functions + +The `write_file.py` module provides functions for writing text files in binary mode. + +### write_text_in_binary_mode + +Write text to a file in binary mode given a directory and file name. + +#### Args + +- **directory (str)**: The directory where the file will be written. +- **file_name (str)**: The name of the file to be written. +- **text (bytes)**: The text to be written to the file. + +#### Returns + +- **str**: The absolute file path of the written file. + +#### Raises + +- **Exception**: If one or more arguments are empty. +- **OSError**: If there is an error writing to the file. + +### write_text_in_binary_mode_abs + +Write text to a file in binary mode given an absolute file path. + +#### Args + +- **absolute_file_path (str)**: The absolute path to the file to be written. +- **text (bytes)**: The text to be written to the file. + +#### Returns + +- **str**: The absolute file path of the written file. + +#### Raises + +- **Exception**: If one or more arguments are empty. +- **OSError**: If there is an error writing to the file. + +## Usage + +```python +from encryption_helper.utils.io import read_file, write_file + +# Read file example +content = read_file.read_text_in_binary_mode('/path/to/directory', 'file.txt') +print(content) + +# Write file example +path = write_file.write_text_in_binary_mode('/path/to/directory', 'file.txt', b'test data') +print(path) +``` + +## License + +This project is licensed under the MIT License. See the [LICENSE](../../../LICENSE) file for details.