#Pass the key you want to import like this: 
#      python3 import-key.py filename_of_public_key.asc
#      python3 import-key.py public-key

from pprint import pprint
import sys
import gnupg
from pathlib import Path
from shutil import which



if which('gpg') is None:
    sys.exit("Please install gnupg in linux")

gpg = gnupg.GPG()
key_data = open(sys.argv[1], encoding="utf-8").read()
import_result = gpg.import_keys(key_data)
pprint(import_result.results)

public_keys = gpg.list_keys()
pprint(public_keys)
