Python GNUPG - 信任导入的密钥?

Python GNUPG - Trust Imported Key?

与此类似:

但我想在 Python 内设置导入密钥对的信任级别。这可能吗?如果是,怎么做?

在尝试使用 public 密钥加密文件后,我收到了消息:

"There is no assurance this key belongs to the named user\r\n[GNUPG:] INV_RECP 10 TestUser@Company.Com\r\n[GNUPG:] FAILURE sign-encrypt 53\r\ngpg: [stdin]: sign+encrypt failed: Unusable public key\r\n"

这是在 运行 之后:

with open('Test.txt', 'rb') as f:
                status = gpg.encrypt_file(
                    f,sign=public_key_fingerprint,
                    recipients=private_key_recipient,
                    output = output_file
                )

status.status returns:

'invalid recipient'

编辑:

private_key_recipient = 'TestUser@Company.Com'

看着 pydoc gnupg 我明白了:

trust_keys(self, fingerprints, trustlevel) 

它没有记录,但它听起来像你想要的。