|
| 1 | +<!-- markdownlint-disable MD033 MD041 --> |
| 2 | +<p align="center"> |
| 3 | + <img src="https://www.hsbc.com/-/files/hsbc/header/hsbc-logo-200x25.svg" alt="HSBC Logo" width="200" title="HSBC Logo"> |
| 4 | +</p> |
| 5 | + |
| 6 | +<h1 align="center">Encryption Helper Python</h1> |
| 7 | + |
| 8 | +<p align="center"> |
| 9 | + <img src="../../../assets/banner.jpg" alt="Encryption Helper Banner"> |
| 10 | +</p> |
| 11 | + |
| 12 | +<h2 align="center">I/O Modules</h2> |
| 13 | + |
| 14 | +<p align="center"> |
| 15 | + <strong>I/O modules for the encryption_helper package.</strong> |
| 16 | +</p> |
| 17 | + |
| 18 | +<p align="center"> |
| 19 | + <a href="#read-file-functions">Read File Functions</a> • |
| 20 | + <a href="#write-file-functions">Write File Functions</a> • |
| 21 | + <a href="#usage">Usage</a> • |
| 22 | + <a href="#license">License</a> |
| 23 | +</p> |
| 24 | +<!-- markdownlint-enable MD033 MD041 --> |
| 25 | + |
| 26 | +## Read File Functions |
| 27 | + |
| 28 | +The `read_file.py` module provides functions for reading text files in binary mode. |
| 29 | + |
| 30 | +### read_text_in_binary_mode |
| 31 | + |
| 32 | +Read text from a file in binary mode given a directory and file name. |
| 33 | + |
| 34 | +#### Args |
| 35 | + |
| 36 | +- **directory (str)**: The directory where the file is located. |
| 37 | +- **file_name (str)**: The name of the file to be read. |
| 38 | + |
| 39 | +#### Returns |
| 40 | + |
| 41 | +- **bytes**: The content of the file read in binary mode. |
| 42 | + |
| 43 | +#### Raises |
| 44 | + |
| 45 | +- **Exception**: If one or more arguments are empty. |
| 46 | +- **OSError**: If there is an error reading the file. |
| 47 | + |
| 48 | +### read_text_in_binary_mode_abs |
| 49 | + |
| 50 | +Read text from a file in binary mode given an absolute file path. |
| 51 | + |
| 52 | +#### Args |
| 53 | + |
| 54 | +- **absolute_file_path (str)**: The absolute path to the file to be read. |
| 55 | + |
| 56 | +#### Returns |
| 57 | + |
| 58 | +- **bytes**: The content of the file read in binary mode. |
| 59 | + |
| 60 | +#### Raises |
| 61 | + |
| 62 | +- **Exception**: If one or more arguments are empty. |
| 63 | +- **OSError**: If there is an error reading the file. |
| 64 | + |
| 65 | +## Write File Functions |
| 66 | + |
| 67 | +The `write_file.py` module provides functions for writing text files in binary mode. |
| 68 | + |
| 69 | +### write_text_in_binary_mode |
| 70 | + |
| 71 | +Write text to a file in binary mode given a directory and file name. |
| 72 | + |
| 73 | +#### Args |
| 74 | + |
| 75 | +- **directory (str)**: The directory where the file will be written. |
| 76 | +- **file_name (str)**: The name of the file to be written. |
| 77 | +- **text (bytes)**: The text to be written to the file. |
| 78 | + |
| 79 | +#### Returns |
| 80 | + |
| 81 | +- **str**: The absolute file path of the written file. |
| 82 | + |
| 83 | +#### Raises |
| 84 | + |
| 85 | +- **Exception**: If one or more arguments are empty. |
| 86 | +- **OSError**: If there is an error writing to the file. |
| 87 | + |
| 88 | +### write_text_in_binary_mode_abs |
| 89 | + |
| 90 | +Write text to a file in binary mode given an absolute file path. |
| 91 | + |
| 92 | +#### Args |
| 93 | + |
| 94 | +- **absolute_file_path (str)**: The absolute path to the file to be written. |
| 95 | +- **text (bytes)**: The text to be written to the file. |
| 96 | + |
| 97 | +#### Returns |
| 98 | + |
| 99 | +- **str**: The absolute file path of the written file. |
| 100 | + |
| 101 | +#### Raises |
| 102 | + |
| 103 | +- **Exception**: If one or more arguments are empty. |
| 104 | +- **OSError**: If there is an error writing to the file. |
| 105 | + |
| 106 | +## Usage |
| 107 | + |
| 108 | +```python |
| 109 | +from encryption_helper.utils.io import read_file, write_file |
| 110 | + |
| 111 | +# Read file example |
| 112 | +content = read_file.read_text_in_binary_mode('/path/to/directory', 'file.txt') |
| 113 | +print(content) |
| 114 | + |
| 115 | +# Write file example |
| 116 | +path = write_file.write_text_in_binary_mode('/path/to/directory', 'file.txt', b'test data') |
| 117 | +print(path) |
| 118 | +``` |
| 119 | + |
| 120 | +## License |
| 121 | + |
| 122 | +This project is licensed under the MIT License. See the [LICENSE](../../../LICENSE) file for details. |
0 commit comments