aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python (follow)
Commit message (Collapse)AuthorAgeFilesLines
* core: Document the version a function has been deprecated.Werner Koch2016-09-161-1/+1
| | | | | | | | | * src/gpgme.h.in (_GPGME_DEPRECATED): Change to take versio numbers for documentation. Change all places. (_GPGME_DEPRECATED_OUTSIDE_GPGME): Ditto. * lang/python/gpgme-h-clean.py: Adjust RE. Signed-off-by: Werner Koch <[email protected]>
* python: Release the GIL during calls into GPGME.Justus Winter2016-09-162-7/+45
| | | | | | | | | | | | | | | * lang/python/helpers.c (pyme_raise_callback_exception): Re-acquire the Global Interpreter Lock. (pyPassphraseCb, pyme_set_passphrase_cb, pyProgressCb, pyme_set_progress_cb, pyStatusCb, pyme_set_status_cb, _pyme_interact_cb, pyDataReadCb, pyDataWriteCb, pyDataSeekCb, pyDataReleaseCb, pyme_data_new_from_cbs, _pyme_assuan_data_cb, _pyme_assuan_inquire_cb, _pyme_assuan_status_cb): Likewise. * lang/python/setup.py.in: Make 'gpgme-config' emit the correct cflags, and SWIG generate code to release the GIL before calling us. Co-authored-by: Kai Michaelis <[email protected]> Signed-off-by: Justus Winter <[email protected]>
* python: Adapt to 'gpgme_op_interact'.Justus Winter2016-09-168-38/+296
| | | | | | | | | | | | | | | | | | * 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]>
* python: Clarify that we support Python 2.7 too.Justus Winter2016-09-143-3/+3
| | | | | | | | * lang/python/README: Use 'Python' instead of 'Python 3'. * lang/python/pyme/version.py.in: Likewise. * lang/python/setup.py.in: Add classifier for 2.7, drop 3 only. Signed-off-by: Justus Winter <[email protected]>
* python: Trim imports.Justus Winter2016-09-144-4/+0
| | | | | | | | | * lang/python/examples/encrypt-to-all.py: Drop unused import of 'os'. * lang/python/examples/signverify.py: Likewise. * lang/python/examples/simple.py: Likewise. * lang/python/examples/verifydetails.py: Likewise. Signed-off-by: Justus Winter <[email protected]>
* python: Improve error handling.Justus Winter2016-09-141-2/+12
| | | | | | * lang/python/gpgme.i (gpgme_engine_info_t): Improve error handling. Signed-off-by: Justus Winter <[email protected]>
* python: Adapt to TOFU changes.Justus Winter2016-09-141-4/+1
| | | | | | | * lang/python/pyme/results.py (TofuInfo): Drop. (Signature): The TOFU information moved to the key. Signed-off-by: Justus Winter <[email protected]>
* python: Build for both Python2 and Python3.Justus Winter2016-09-143-9/+122
| | | | | | | | | | * NEWS: Update. * configure.ac: Check for multiple Python versions. * lang/python/Makefile.am: Build and install for both Python versions. * lang/python/tests/Makefile.am: Test both versions. * lang/python/tests/run-tests.py: New test runner. Signed-off-by: Justus Winter <[email protected]>
* python: Import from __future__ to align behavior of Python 2.7.Justus Winter2016-09-1459-0/+177
| | | | | -- Signed-off-by: Justus Winter <[email protected]>
* python: Use more generic shebang.Justus Winter2016-09-1438-38/+38
| | | | | -- Signed-off-by: Justus Winter <[email protected]>
* python: Handle slight differences between Python 2 and 3.Justus Winter2016-09-136-32/+61
| | | | | | | | | | | | | | | | | | | * lang/python/helpers.c (pyDataWriteCb): Handle Python integers being returned on Python 2. (pyDataSeekCb): Likewise. * lang/python/pyme/core.py (Data.__init__): Fix testing for string argument. (Data.new_from_filepart): Likewise. * lang/python/pyme/util.py (is_a_string): New function. * lang/python/tests/t-encrypt-large.py (read_cb): Force evaluation of generator. * lang/python/tests/t-idiomatic.py: Partly skip test on Python 2. * lang/python/tests/t-verify.py (check_result): Here, the difference between 2 and 3 really matters. We cannot change the char * conversion in Python 2 without breaking all existing applications, and using bytestrings in Python 3 would be very inconvenient. Signed-off-by: Justus Winter <[email protected]>
* python: Fix types and error handling.Justus Winter2016-09-131-11/+26
| | | | | | | * lang/python/helpers.c (_pyme_edit_cb): Drop the const. (_pyme_assuan_{data,inquire,status}_cb): Fix error handling. Signed-off-by: Justus Winter <[email protected]>
* python: Avoid Python3-only form of super().Justus Winter2016-09-121-4/+5
| | | | | | | | | | * lang/python/pyme/core.py (GpgmeWrapper.__repr__): Use more compatible form of super. (GpgmeWrapper.__setattr__): Likewise. (Context.__init__): Likewise. (Data.__init__): Likewise. Signed-off-by: Justus Winter <[email protected]>
* python: Make type translation compatible with Python 2.7.Justus Winter2016-09-122-13/+78
| | | | | | | * lang/python/gpgme.i: Avoid functions not available in Python 2.7. * lang/python/helpers.c: Likewise. Signed-off-by: Justus Winter <[email protected]>
* python: Avoid hardcoding the interpreter.Justus Winter2016-09-121-2/+2
| | | | | | * lang/python/setup.py.in: Avoid hardcoding the interpreter. Signed-off-by: Justus Winter <[email protected]>
* python: Do not rely on subprocess.DEVNULL.Justus Winter2016-09-121-2/+7
| | | | | | * lang/python/setup.py.in: Do not rely on subprocess.DEVNULL. Signed-off-by: Justus Winter <[email protected]>
* tests: Make signature notation test compatible with older GnuPGs.Justus Winter2016-09-121-1/+10
| | | | | | | | | * lang/python/tests/t-sig-notation.py: Only check the critical flag when GnuPG >= 2.1.13 is used. * tests/gpg/t-sig-notation.c: Likewise. Fixes-commit: c88c9ef3 Signed-off-by: Justus Winter <[email protected]>
* Prepend LD_LIBRARY_PATH for python testsAndre Heinecke2016-08-081-1/+1
| | | | | | | | | | | * lang/python/tests/Makefile.am (TESTS_ENVIRONMENT): Prepend path instead of setting the value. -- This fixes the case where tools / libararies are needed for a working GnuPG system that are pointed to by LD_LIBRARY_PATH. E.g. GnuPG itself is installed in a custom prefix and PATH / LD_LIBRARY_PATH is set accordingly.
* python: Clean up and modernize examples.Justus Winter2016-08-0514-500/+360
| | | | | | | | | | | | | | | | | | | | * lang/python/examples/Examples.rst: Delete file. * lang/python/examples/t-edit.py: Likewise. This is actually a test case and has been moved to 'tests'. * lang/python/examples/assuan.py: New file. * lang/python/examples/decryption-filter.py: Likewise. * lang/python/examples/delkey.py: Modernize. * lang/python/examples/encrypt-to-all.py: Likewise. * lang/python/examples/exportimport.py: Likewise. * lang/python/examples/genkey.py: Likewise. * lang/python/examples/inter-edit.py: Likewise. * lang/python/examples/sign.py: Likewise. * lang/python/examples/signverify.py: Likewise. * lang/python/examples/simple.py: Likewise. * lang/python/examples/testCMSgetkey.py: Likewise. * lang/python/examples/verifydetails.py: Likewise. Signed-off-by: Justus Winter <[email protected]>
* python: Add a nicer interface to list keys.Justus Winter2016-08-032-1/+16
| | | | | | | * lang/python/pyme/core.py (Context.keylist): New method. * lang/python/tests/t-keylist.py: Test new method. Signed-off-by: Justus Winter <[email protected]>
* python: Add a flag identifying in-tree builds.Justus Winter2016-08-024-1/+24
| | | | | | | | | | * lang/python/helpers.c (pyme_in_tree_build): New variable. * lang/python/helpers.h (pyme_in_tree_build): New declaration. * lang/python/pyme/version.py.in (in_tree_build): New variable. * lang/python/setup.py.in: Rework macro handling, set 'IN_TREE_BUILD' as appropriate. Signed-off-by: Justus Winter <[email protected]>
* python: Fix build system integration.Justus Winter2016-08-021-3/+17
| | | | | | | * lang/python/Makefile.am: Be more careful when cleaning the build directory, we must not delete the generated file 'pyme/version.py'. Signed-off-by: Justus Winter <[email protected]>
* python: Fix out-of-tree build.Justus Winter2016-07-281-1/+1
| | | | | | | * lang/python/MANIFEST.in: Add 'private.h'. Fixes-commit: 3d4dc3f0 Signed-off-by: Justus Winter <[email protected]>
* python: Improve error handling.Justus Winter2016-07-281-8/+18
| | | | | | | | * lang/python/pyme/core.py (Context.protocol): Check that the engine is usable before setting the protocol. (Context._errorcheck): Add missing functions. Signed-off-by: Justus Winter <[email protected]>
* python: Drop superfluous imports and trim public interface.Justus Winter2016-07-288-9/+27
| | | | | | | | | | | | | | | * lang/python/pyme/__init__.py: Avoid leaking low-level 'gpgme', make sure the main module looks nice and tidy, appease pyflakes. * lang/python/pyme/errors.py: Appease pyflakes. * lang/python/pyme/util.py: Avoid leaking low-level 'gpgme' into the module namespace. * lang/python/pyme/version.py.in: Likewise. * lang/python/tests/t-keylist.py: Drop superfluous imports. * lang/python/tests/t-sig-notation.py: Likewise. * lang/python/tests/t-sign.py: Likewise. * lang/python/tests/t-signers.py: Likewise. Signed-off-by: Justus Winter <[email protected]>
* python: Rename compiled SWIG module.Justus Winter2016-07-287-115/+115
| | | | | | | | | | | | | | | | | Avoid the name pygpgme, as this is the name of another popular Python binding for GPGME. This commit renames the compiled Python module produced by SWIG. * lang/python/Makefile.am: Rename the compiled Python module. * lang/python/gpgme.i: Likewise. * lang/python/pyme/core.py: Likewise. * lang/python/pyme/errors.py: Likewise. * lang/python/pyme/util.py: Likewise. * lang/python/pyme/version.py.in: Likewise. * lang/python/setup.py.in: Likewise. Signed-off-by: Justus Winter <[email protected]>
* python: Rename exported functions.Justus Winter2016-07-283-28/+28
| | | | | | | | | | | | | | Avoid the name pygpgme, as this is the name of another popular Python binding for GPGME. This commit renames all functions that are exported to the Python world. * lang/python/helpers.c: Rename all exported functions. * lang/python/helpers.h: Likewise. * lang/python/pyme/core.py: Likewise. Signed-off-by: Justus Winter <[email protected]>
* python: Rename private functions.Justus Winter2016-07-284-72/+77
| | | | | | | | | | | | | | | | Avoid the name pygpgme, as this is the name of another popular Python binding for GPGME. This commit renames all functions that are not exported to the Python world. * lang/python/gpgme.i: Rename all private functions. * lang/python/helpers.c: Likewise. * lang/python/helpers.h: Likewise. * lang/python/private.h: Likewise. Also move the SWIG runtime helper prototypes here. Signed-off-by: Justus Winter <[email protected]>
* python: Support the Assuan engine.Justus Winter2016-07-287-1/+302
| | | | | | | | | | | | | | * lang/python/gpgme.i: Add typemaps for the Assuan protocol callbacks. * lang/python/helpers.c (_pyme_assuan_{data,inquire,status}_cb): New functions. * lang/python/private.h (_pyme_assuan_{data,inquire,status}_cb): New prototypes. * lang/python/pyme/core.py (Context.assuan_transact): New method. * lang/python/pyme/util.py (percent_escape): New function. * lang/python/tests/Makefile.am (py_tests): Add new test. * lang/python/tests/t-protocol-assuan.py: New file. Signed-off-by: Justus Winter <[email protected]>
* python: Improve engine information handling.Justus Winter2016-07-283-9/+54
| | | | | | | | | * lang/python/gpgme.i (gpgme_engine_info_t): Wrap engine infos. * lang/python/pyme/core.py (Context.engine_info): New property. (Context.{g,s}et_engine_info): Improve docstrings. * lang/python/pyme/results.py (EngineInfo): New class. Signed-off-by: Justus Winter <[email protected]>
* python: Add accessors for the protocol.Justus Winter2016-07-281-0/+11
| | | | | | | | * lang/python/pyme/core.py (Context.__init__): Add 'protocol' parameter. (Context.protocol): New accessors. Signed-off-by: Justus Winter <[email protected]>
* python: Expose less functions to the Python world.Justus Winter2016-07-285-15/+46
| | | | | | | | | | * lang/python/Makefile.am (EXTRA_DIST, COPY_FILES): Add new file. * lang/python/gpgme.i: Include new file and add comments. * lang/python/helpers.c: Include new file. * lang/python/helpers.h: Move functions we do not need to expose... * lang/python/private.h: ... here. Signed-off-by: Justus Winter <[email protected]>
* python: Make GPGME's version easily accessible.Justus Winter2016-07-151-4/+3
| | | | | | * lang/python/pyme/version.py.in (gpgme_versionstr): New variable. Signed-off-by: Justus Winter <[email protected]>
* python: Add an idiomatic interface.Justus Winter2016-07-1519-131/+773
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac: Bump required Python version. * lang/python/pyme/__init__.py: Update docstring. Import Context and Data. * lang/python/pyme/core.py (Context.encrypt): New function. (Context.decrypt): Likewise. (Context.sign): Likewise. (Context.verify): Likewise. * lang/python/pyme/errors.py: Add new errors. * lang/python/pyme/util.py (process_constants): Rework and return the inserted keys. * lang/python/tests/Makefile.am (EXTRA_DIST): Add new keys. * lang/python/tests/encrypt-only.asc: New file. * lang/python/tests/sign-only.asc: Likewise. * lang/python/tests/initial.py: Mark key 'Alpha' as trusted, import new keys. * lang/python/tests/support.py: Add fingerprints of known keys. (in_srcdir): New function. (print_data): Handle bytes too. (mark_key_trusted): New function. * lang/python/tests/t-decrypt-verify.py: Adjust test. Test idiomatic interface. * lang/python/tests/t-decrypt.py: Test idiomatic interface. * lang/python/tests/t-encrypt-sign.py: Likewise. * lang/python/tests/t-encrypt-sym.py: Likewise. * lang/python/tests/t-encrypt.py: Likewise. * lang/python/tests/t-idiomatic.py: Simplify. * lang/python/tests/t-keylist.py: Adjust to newly trusted key. * lang/python/tests/t-sign.py: Likewise. Test idiomatic interface. * lang/python/tests/t-signers.py: Likewise. * lang/python/tests/t-verify.py: Likewise. Signed-off-by: Justus Winter <[email protected]>
* python: Fix test.Justus Winter2016-07-141-13/+5
| | | | | | | * lang/python/tests/t-keylist.py: Do not assume key alpha is trusted yet. Signed-off-by: Justus Winter <[email protected]>
* python: Drop bad category.Justus Winter2016-07-141-1/+0
| | | | | -- Signed-off-by: Justus Winter <[email protected]>
* python: Port more tests.Justus Winter2016-07-125-6/+335
| | | | | | | | | | | | | * lang/python/pyme/core.py (Context.op_keylist_all): Add missing 'op_keylist_end'. (Context.op_trustlist_all): Fix function. Add missing 'op_trustlist_end'. * lang/python/tests/Makefile.am (pytests): Add new files. * lang/python/tests/t-import.py: New file. * lang/python/tests/t-keylist.py: Likewise. * lang/python/tests/t-trustlist.py: Check alternate interface. Signed-off-by: Justus Winter <[email protected]>
* python: Improve python packaging.Justus Winter2016-07-122-3/+26
| | | | | | | * lang/python/Makefile.am: Sign source releases, and upload them. * lang/python/setup.py.in: Add categories. Signed-off-by: Justus Winter <[email protected]>
* python: Fix distcheck.Justus Winter2016-07-111-0/+2
| | | | | | * lang/python/Makefile.am (EXTRA_DIST): Add missing files. Signed-off-by: Justus Winter <[email protected]>
* python: Enable out-of-tree build of pyme bindings.Justus Winter2016-07-114-29/+99
| | | | | | | | | | | * lang/python/MANIFEST.in: Update manifest template. * lang/python/Makefile.am: Copy more files, move generation of files to Python build script, add 'sdist' target to build a Python source distribution. * lang/python/gpgme-h-clean.py: Add code to build 'errors.i'. * lang/python/setup.py.in: Generate files, enable out-of-tree builds. Signed-off-by: Justus Winter <[email protected]>
* python: Do not depend on access to internal data structures.Justus Winter2016-07-112-45/+76
| | | | | | | | * lang/python/gpgme.i (gpgme_data_t): Rework so that it works without access to the definition of 'struct gpgme_data'. * lang/python/helpers.c (object_to_gpgme_data_t): Add assertion. Signed-off-by: Justus Winter <[email protected]>
* python: Make result wrapping backwards compatible.Justus Winter2016-07-111-5/+4
| | | | | | * lang/python/pyme/results.py (Result.__init__): Skip missing fields. Signed-off-by: Justus Winter <[email protected]>
* python: Fix raising stashed exceptions.Justus Winter2016-07-081-1/+7
| | | | | | | | | Fixes an issue with newer versions of Python. * lang/python/helpers.c (pygpgme_raise_callback_exception): Be more careful when restoring the exception. Signed-off-by: Justus Winter <[email protected]>
* python: Fix distcheck.Justus Winter2016-07-075-23/+68
| | | | | | | | | | | | | | * lang/python/INSTALL: Drop obsolete file. * lang/python/Makefile.am (EXTRA_DIST): Add missing files. (CLEANFILES): Remove generated files. (clean-local): Fix permissions of copied files. * lang/python/tests/Makefile.am (TESTS): Use our own setup and teardown scripts. (EXTRA_DIST): Add missing files. * lang/python/tests/final.py: New file. * lang/python/tests/initial.py: Likewise. Signed-off-by: Justus Winter <[email protected]>
* python: Improve autmatically generated docstrings.Justus Winter2016-06-162-10/+23
| | | | | | | | * lang/python/gpgme.i: Add comment. * lang/python/pyme/core.py (__getattr__): Rewrite automatically generated doctrings for the wrapper methods. Signed-off-by: Justus Winter <[email protected]>
* python: Make result objects more robust.Justus Winter2016-06-164-4/+224
| | | | | | | | | | | | | | | | Results returned by the GPGME are fragile, i.e. they are only valid until the next operation is performed in the context. We cannot arbitrarily constrain the lifetime of Python objects, we therefore create deep copies of the results. * lang/python/gpgme.i (gpgme_tofu_info_t): Turn these into a list. (gpgme_*_result_t): Create deep copies of these objects. * lang/python/helpers.c (pygpgme_wrap_fragile_result): New function. * lang/python/helpers.h (pygpgme_wrap_fragile_result): New prototype. * lang/python/pyme/results.py: New file. Signed-off-by: Justus Winter <[email protected]>
* python: Avoid creating SWIG proxy classes.Justus Winter2016-06-162-2/+2
| | | | | | | | * lang/python/Makefile.am (gpgme_wrap.c): Use '-builtin' to make SWIG generate builtin types for c types. * lang/python/gpgme.i (pygpgme_wrap_gpgme_data_t): Adapt slightly. Signed-off-by: Justus Winter <[email protected]>
* python: Simplify wrapping glue.Justus Winter2016-06-162-23/+22
| | | | | | | | * lang/python/pyme/core.py: Rename '_getctype' to '_ctype' and turn it into a string. Likewise rename '_getnameprepend' to '_cprefix'. * lang/python/helpers.c: Adapt accordingly. Signed-off-by: Justus Winter <[email protected]>
* python: Rework callbacks.Justus Winter2016-06-164-89/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | Simplify how the lifetime of callback arguments is managed. * lang/python/gpgme.i (gpgme_edit_cb_t): Check arguments. (PyObject_p_p, void_p_p): Drop rather dangerous interface. (pygpgme_unwrap_gpgme_ctx_t): New function. * lang/python/helpers.c (pygpgme_clear_generic_cb): Drop dangerous function. (pyPassphraseCb): Assert contract. (pygpgme_set_passphrase_cb): Use Python's calling convention so that we can raise exceptions. Hand in 'self', get the wrapped object, and simply store the hook data as attribute of the wrapper object. (pyProgressCb, pygpgme_set_progress_cb): Likewise. (pygpgme_set_status_cb): Likewise. (pygpgme_data_new_from_cbs): Likewise. * lang/python/helpers.h (pygpgme_clear_generic_cb): Drop prototype. (pygpgme_set_passphrase_cb): Update prototype. (pygpgme_set_progress_cb): Likewise. (pygpgme_set_status_cb): Likewise. (pygpgme_data_new_from_cbs): Likewise. (pygpgme_unwrap_gpgme_ctx_t): New prottotype. * lang/python/pyme/core.py (Context, Data): Update callsites. Signed-off-by: Justus Winter <[email protected]>
* python: Wrap objects implementing the buffer protocol.Justus Winter2016-06-165-63/+179
| | | | | | | | | | | | | | | | | * lang/python/Makefile.am: Add the toplevel source directory to CFLAGS when compiling the bindings so that we can use private header files. * lang/python/gpgme.i (gpgme_data_t): Rework the object wrapping. Do not create a Python wrapper object, merely a gpgme_data_t object, and keep references to buffer objects, if any. If necessary, update the buffer after the function call. (pygpgme_wrap_gpgme_data_t): New function. * lang/python/helpers.c (object_to_gpgme_data_t): Rework object wrapping. Also wrap objects implementing the buffer protocol. * lang/python/helpers.h (object_to_gpgme_data_t): Update prototype. (pygpgme_wrap_gpgme_data_t): New prototype. * lang/python/tests/t-idiomatic.py: Demonstrate this. Signed-off-by: Justus Winter <[email protected]>