pyme
GPGmeの情報が少ないため備忘録代わりに。
インストール
まず、Ubuntu 16.04では最新のpymeを入れようとすると1.7以上でないと怒られます。
最新のリポジトリ(zesty 1.7)は対応しているっぽいですが、16.*では1.6止まりのようです。
http://packages.ubuntu.com/search?keywords=libgpgme11
GPGme1.8をインストールの四苦八苦はGPGme with Qt5を参照下さい。
Context
何をするにもまずContextを作ります。
import gpg
ctx = gpg.Context()
Contextは以下のメンバを持ちます。
- armor
- card_edit
- decrypt
- decrypt_verify
- delete
- edit
- encrypt
- encrypt_sign
- export
- genkey
- get_key
- import_
- include_certs
- keylist
- keylist_mode
- passphrase_cb
- progress_cb
- protocol
- set_engine_info
- set_locale
- sign
- signers
- textmode
- verify
homedir
gpgコマンドの--homedir
オプションに相当するものはengine_infoで扱います。
# protocol, filename, home_dir
ctx.set_engine_info(gpg.constants.PROTOCOL_OpenPGP, None, ".")
tupleでしか引数を受け取ってくれないのが少し不便です。
- protocol
- filename
- home_dir