MCPcopy Index your code
hub / github.com/dbcli/mycli / open_mylogin_cnf

Function open_mylogin_cnf

mycli/config.py:118–138  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

116
117
118def 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
141def read_and_decrypt_mylogin_cnf(f: BinaryIO) -> BytesIO | None:

Callers 3

__init__Method · 0.90
test_read_mylogin_cnfFunction · 0.90

Calls 2

errorMethod · 0.45

Tested by 2

test_read_mylogin_cnfFunction · 0.72