It would be nice if the python Context object had import and export functions.
I've thus attached a patch based on this one submitted a while ago to gnupg-devel by Tobias Mueller:
It's pretty much exactly the same, I just updated export to use the new read helper function.
Commit message from the original patch:
python: Add more python import and export functions.
- lang/python/gpg/core.py (Context): Added import_ and export
- lang/python/tests/t-export.py: New test for export function
- lang/python/tests/t-import.py: New test for import function
- lang/python/tests/t-op-export.py: Renamed from t-export.py
- lang/python/tests/t-op-import.py: Renamed from t-import.py
gpgme's op_import and op_export functions return an error code rather
than a result. In Python, exceptions are thrown if any of those
functions returned an error code. This change gives a more natural
import and export function which return the result object or throw on
Signed-off-by: Tobias Mueller <muelli at cryptobitch.de>