def import_pgp(keyring, keydata):
    """
    keydata should be public key data to be imported to the keyring.
    The return value will be the sha1 fingerprint of the public key added.
    """

    out, err, ret = run_command([
        "gpg", "--batch", "--status-fd", "1"
        "--no-default-keyring", "--keyring", keyring,
        "--import"
    ], input=keydata)

    fingerprint = None
    for line in out.split("\n"):
        data = line.split()
        if not data or data[0] != "[GNUPG:]":
            continue

        if data[1] == "IMPORT_OK":
            fingerprint = data[3]
            break
    else:
        raise ValueError("GPG failed to import pgp public key")

    return fingerprint
dataset/ETHPy150Open Debian/debile/debile/master/keyrings.py/import_pgp/original