Open a readable version of .mylogin.cnf. Returns the file contents as a TextIOWrapper object. :param str name: The pathname of the file to be opened. :return: the login path file or None
(name: str)
| 116 | |
| 117 | |
| 118 | def open_mylogin_cnf(name: str) -> TextIOWrapper | None: |
| 119 | """Open a readable version of .mylogin.cnf. |
| 120 | |
| 121 | Returns the file contents as a TextIOWrapper object. |
| 122 | |
| 123 | :param str name: The pathname of the file to be opened. |
| 124 | :return: the login path file or None |
| 125 | """ |
| 126 | |
| 127 | try: |
| 128 | with open(name, "rb") as f: |
| 129 | plaintext = read_and_decrypt_mylogin_cnf(f) |
| 130 | except (OSError, IOError, ValueError): |
| 131 | logger.error("Unable to open login path file.") |
| 132 | return None |
| 133 | |
| 134 | if not isinstance(plaintext, BytesIO): |
| 135 | logger.error("Unable to read login path file.") |
| 136 | return None |
| 137 | |
| 138 | return TextIOWrapper(plaintext) |
| 139 | |
| 140 | |
| 141 | def read_and_decrypt_mylogin_cnf(f: BinaryIO) -> BytesIO | None: |