def get_credentials(username=None):
while not check_secret():<EOL><INDENT>pass<EOL><DEDENT>while True:<EOL><INDENT>try:<EOL><INDENT>with open(SECRET_FILE, "<STR_LIT:r>") as f:<EOL><INDENT>lines = [line.strip().split("<STR_LIT::>", <NUM_LIT:2>) for line in f.readlines()]<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>msg = '<STR_LIT>'<EOL>raise Exception(msg.format(SECRET_FILE))<EOL><DEDENT>if username is not None:<EOL><INDENT>for login, password in lines:<EOL><INDENT>if login == username.strip():<EOL><INDENT>return login, password<EOL><DEDENT><DEDENT><DEDENT>print("<STR_LIT>")<EOL>for ind, (login, password) in enumerate(lines):<EOL><INDENT>print("<STR_LIT>" % (ind + <NUM_LIT:1>, login))<EOL><DEDENT>print("<STR_LIT>" % (<NUM_LIT:0>, "<STR_LIT>"))<EOL>print("<STR_LIT>" % (-<NUM_LIT:1>, "<STR_LIT>"))<EOL>try:<EOL><INDENT>ind = int(sys.stdin.readline())<EOL>if ind == <NUM_LIT:0>:<EOL><INDENT>add_credentials()<EOL>continue<EOL><DEDENT>elif ind == -<NUM_LIT:1>:<EOL><INDENT>delete_credentials()<EOL>check_secret()<EOL>continue<EOL><DEDENT>elif <NUM_LIT:0> <= ind - <NUM_LIT:1> < len(lines):<EOL><INDENT>return lines[ind - <NUM_LIT:1>]<EOL><DEDENT><DEDENT>except Exception:<EOL><INDENT>print("<STR_LIT>")<EOL><DEDENT><DEDENT>
Returns login and password stored in `secret.txt`.