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/tests/t-edit.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lang/python/tests') diff --git a/lang/python/tests/t-edit.py b/lang/python/tests/t-edit.py index 9ba187d5..18bcb94e 100755 --- a/lang/python/tests/t-edit.py +++ b/lang/python/tests/t-edit.py @@ -33,7 +33,7 @@ class KeyEditor(object): self.done = False self.verbose = int(os.environ.get('verbose', 0)) > 1 - def edit_fnc(self, status, args, out): + def edit_fnc(self, status, args, out=None): if args == "keyedit.prompt": result = self.steps[self.step] self.step += 1 @@ -57,8 +57,15 @@ c = core.Context() c.set_pinentry_mode(constants.PINENTRY_MODE_LOOPBACK) c.set_passphrase_cb(lambda *args: "abc") c.set_armor(True) -sink = core.Data() +# The deprecated interface. +editor = KeyEditor() +c.interact(c.get_key("A0FF4590BB6122EDEF6E3C542D727CC768697734", False), + editor.edit_fnc) +assert editor.done + +# The deprecated interface. +sink = core.Data() editor = KeyEditor() c.op_edit(c.get_key("A0FF4590BB6122EDEF6E3C542D727CC768697734", False), editor.edit_fnc, sink, sink) -- cgit v1.2.3