#!/usr/bin/env python3

import os
import sys

cmd = "/usr/bin/security 2>&1 >/dev/null find-generic-password -a %s -g" % sys.argv[1]
line = os.popen(cmd).readline()  # noqa: S605
passwds = line.split()
if len(passwds) == 2:
    print(passwds[1][1:-1])
else:
    raise RuntimeError("Didn't understand the format of `security`'s response")
