diff options
author | Justus Winter <[email protected]> | 2016-09-16 12:56:29 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2016-09-16 12:56:29 +0000 |
commit | a458e7fe2006d92bd5a838e2747fb66bbac4b1b8 (patch) | |
tree | 7460cc8f3ba21fec51a0a706f17747887ef37d96 /lang/python/examples/inter-edit.py | |
parent | core: Fix typos. (diff) | |
download | gpgme-a458e7fe2006d92bd5a838e2747fb66bbac4b1b8.tar.gz gpgme-a458e7fe2006d92bd5a838e2747fb66bbac4b1b8.zip |
python: Adapt to 'gpgme_op_interact'.
* lang/python/examples/inter-edit.py: Update example.
* lang/python/gpgme.i (gpgme_edit_cb_t): Turn into
'gpgme_interact_cb_t'.
* lang/python/helpers.c (_pyme_edit_cb): Turn into
'_pyme_interact_cb_t'.
* lang/python/private.h (_pyme_edit_cb): Likewise.
* lang/python/pyme/constants/__init__.py: Replace numeric status codes
with the keywords.
* lang/python/pyme/constants/status.py: Likewise.
* lang/python/pyme/core.py (Context.interact): New method.
(Context.op_edit): Deprecate, update docstring, implement using
Context.interact.
* lang/python/tests/t-edit.py: Test both interfaces.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to '')
-rw-r--r-- | lang/python/examples/inter-edit.py | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/lang/python/examples/inter-edit.py b/lang/python/examples/inter-edit.py index 459df114..39d6f176 100644 --- a/lang/python/examples/inter-edit.py +++ b/lang/python/examples/inter-edit.py @@ -23,13 +23,6 @@ del absolute_import, print_function, unicode_literals import sys import pyme -import pyme.constants.status - -# Get names for the status codes -status2str = {} -for name in dir(pyme.constants.status): - if not name.startswith('__') and name != "util": - status2str[getattr(pyme.constants.status, name)] = name if len(sys.argv) != 2: sys.exit("Usage: %s <Gpg key pattern>\n" % sys.argv[0]) @@ -46,11 +39,11 @@ with pyme.Context() as c: key = keys[0] print("Editing key {} ({}):".format(key.uids[0].uid, key.subkeys[0].fpr)) - def edit_fnc(status, args): + def edit_fnc(keyword, args): print("Status: {} ({}), args: {} > ".format( - status2str[status], status, args), end='', flush=True) + keyword, status, args), end='', flush=True) - if not 'GET' in status2str[status]: + if not 'GET' in keyword: # no prompt print() return None @@ -60,4 +53,4 @@ with pyme.Context() as c: except EOFError: return "quit" - c.op_edit(key, edit_fnc, None, sys.stdout) + c.interact(key, edit_fnc, sink=sys.stdout) |