From a458e7fe2006d92bd5a838e2747fb66bbac4b1b8 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Fri, 16 Sep 2016 14:56:29 +0200 Subject: 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 --- lang/python/examples/inter-edit.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'lang/python/examples/inter-edit.py') 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 \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) -- cgit v1.2.3