aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/src/core.py (unfollow)
Commit message (Collapse)AuthorFilesLines
2025-02-03python: Remove Python bindingsIngo Klöcker1-1795/+0
* README: Update. * configure.ac: Remove checks, variables and file generations related to the Python bindings. Remove python from available_languages and default_languages. * lang/Makefile.am (DIST_SUBDIRS): Remove python. * lang/python: Remove. * m4/ax_pkg_swig.m4, m4/ax_python_devel.m4, m4/python.m4: Remove. -- The Python bindings have been moved to a separate Git repository: gpgmepy. GnuPG-bug-id: 7262
2023-10-13python,doc: Fix typos in documentation and source code commentsIngo Klöcker1-3/+3
-- Anonymous contribution Signed-off-by: Ingo Klöcker <[email protected]>
2022-08-09python: Don't call __del__ from __exit__ method.NIIBE Yutaka1-2/+2
* lang/python/src/core.py (Context, Data): Don't call __del__ from __exit__ method, as the object may be still in use. * lang/python/tests/t-idiomatic.py: Fix the test. -- GnuPG-bug-id: 6060 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-08-05python: Don't access gpgme with wrapped=None.NIIBE Yutaka1-0/+12
* lang/python/src/core.py (GpgmeWrapper, Context): Check self.wrapped is valid. -- GnuPG-bug-id: 6060 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-08-05python: Reset passphrase callback correctly.Jasper Spaans1-8/+4
* lang/python/src/core.py (Context(GpgmeWrapper)): Reset passphrase callback correctly, for encrypt, decrypt, create_key, and create_subkey methods. -- Signed-off-by: Jasper Spaans <[email protected]>
2021-06-24python: Allow returning signatures made by unknown keys in `decrypt`Jasper Spaans1-3/+9
-- This functionality got dropped somewhere after 1.12, as part of the cleanup of the `Context.decrypt` call signature. Reintroduce it again, now using an explicit keyword argument `filter_signatures` (which defaults to hiding signatures by unknown keys). GnuPG-bug-id: 5292
2020-12-03python: Fix key_export*.NIIBE Yutaka1-3/+3
* lang/python/src/core.py (key_export): Just raise an error. (key_export_minimal, key_export_secret): Ditto. -- GnuPG-bug-id: 5149 Fixes-commit: 7faef33d13fa8efce152ca7aa6e9d39030c1cf08 Signed-off-by: NIIBE Yutaka <[email protected]>
2020-10-27python: Handle the when case __doc__ is None.NIIBE Yutaka1-1/+6
* lang/python/src/core.py (GpgmeWrapper): Check if None. -- GnuPG-bug-id: 5075 Signed-off-by: NIIBE Yutaka <[email protected]>
2019-05-06Python, doc: Minor style improvementAndre Heinecke1-8/+9
* lang/python/src/core.py (Context): Retab and shorten max line length.
2019-05-03python: stop raising BadSignatures from decrypt(verify=True)dkg/fix-T4276Daniel Kahn Gillmor1-13/+9
* src/core.py (decrypt): filter out signatures with errors from the returned verify_result, but avoid raising BadSignatures * tests/t-decrypt-verify.py: ensure that only a single signature is returned when evaluating cipher-3.asc, since the other signature is unknown. -- This change preserves the invariant that decrypt() only ever returns valid signatures in the verify_result, but it avoids unnecessary errors in the face of the presence of an additional bad signature. GnuPG-bug-id: 4276 Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2018-12-05python: overhaul logic of Context.decrypt()Daniel Kahn Gillmor1-33/+35
* lang/python/src/core.py (Context.decrypt): simplify and clarify the logic behind handling verify=False. * lang/python/tests/t-decrypt.py: ensure that we test verify=False -- The function-internal variables were pretty unclear to the reader, and the logic caused pretty nasty breakage when verify=False. GnuPG-Bug-Id: 4271 Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2018-12-05python: ctx.decrypt() has problematic error handlingDaniel Kahn Gillmor1-0/+4
* lang/python/src/core.py (Context.decrypt): document odd error-handling behavior as a potential problem to be addressed. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2018-12-05python: Clarify the meaning of ctx.decrypt(verify=[])Daniel Kahn Gillmor1-1/+4
* lang/python/src/core.py (Context.decrypt): docstring clarification of what it means to pass an empty list to the verify argument. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2018-12-05python: gpg.Context.decrypt verify_sigs and sink_result are boolsDaniel Kahn Gillmor1-5/+5
Both of these function-internal variables are never used for anything other than a binary state. Implement them as the booleans they are. Otherwise, casual readers of the code might think that they're supposed to represent something other than a flag (e.g. "verify_sigs" could mean "the signatures to verify", and "sink_result" could mean "the place where we sink the result"). Signed-Off-By: Daniel Kahn Gillmor <[email protected]>
2018-12-05python: clarify documentation for verify argument for Context.decrypt()Daniel Kahn Gillmor1-1/+2
It's easy to miss that verify can take a list of keys. Make it more obvious to the average python dev who reads docstrings. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2018-12-05python: simplify Context.decrypt()Daniel Kahn Gillmor1-27/+2
In the course of trying to address https://dev.gnupg.org/T4271, i discovered that gpg.Context.decrypt() has a bit of superfluous code. This changeset is intended to simplify the code without making any functional changes. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2018-09-30python bindings: fixing decrypt-verifyBen McGinnes1-5/+6
* lang/python/src/core.py: First restoring the exception to the being just that. * The means to manipulate the error output is temporarily in commented out code, but ought to be added to a proper test later. * In the mean time the original test, with a very slight change, works again. Tested-by: Ben McGinnes <[email protected]> Signed-off-by: Ben McGinnes <[email protected]>
2018-09-30python bindings: ctx.decryptBen McGinnes1-9/+53
* lang/python/src/core.py: Fixed methods of detecting whether verify is a boolean variable or a list. * Added methods of catching the missing keys exceptions. * Still retained PEP8 compliance (which might have been where one or two problems crept in). * Though this is essentially the correct behaviour, it still does not quite fit the otiginal test; so that will also require some adjustment. Tested-by: Ben McGinnes <[email protected]> Signed-off-by: Ben McGinnes <[email protected]>
2018-08-30python bindings: estreams fixben/estreams-fixBen McGinnes1-7/+7
* lang/python/src/core.py: Adjusted new_from_estream function to alias new_from_stream instead of fd. * fixed the _gpgme import errors introduced in commit 08cd34afb762975b0273575035dacf69449ef241 by changing the exported functions/types to match the inner module where all the work is done, rather than the outer one(s). Tested-by: Ben McGinnes <[email protected]> Signed-off-by: Ben McGinnes <[email protected]>
2018-08-29python bindings: coreBen McGinnes1-6/+7
* lang/python/src/core.py: expanded gpgme_error check lists.
2018-08-29python bindings: coreBen McGinnes1-0/+1
* lang/python/src/core.py: added gpgme_data_set_flag to the errorcheck funtion.
2018-08-29python bindings: coreBen McGinnes1-1/+7
* lang/python/src/core.py: added new function new_from_estream to wrap new_from_fd just like new_from_stream does and for the same reason.
2018-08-18Python bindings src: PEP8 complianceBen McGinnes1-1/+2
* import namespace clearance for src/*.py. * Fixed a handful of is/is not None checks as well.
2018-08-10PEP8 compliance and other code fixesBen McGinnes1-98/+141
* Ran all the .py files in src/ and below through Yapf. * Included some manual edits of core.py, this time successfully making two notorious sections a bit more pythonic than scheming. * Left the module imports as is. * This will be committed if it passes the most essential test: compiling, installing and running it. Signed-off-by: Ben McGinnes <[email protected]>
2018-07-01python bindings: scheming serpentsBen McGinnes1-69/+17
* Apparently I am wrong and Scheme is the new Python after all. * Non-import related PEP8 compliance must wait for another day, though the other PEP8 fixes remain.
2018-07-01python bindings: gpg.coreBen McGinnes1-27/+79
* Changed id/else statements to a more pythonic form from scheme masquerading as python - sorry Justus, it had to go ;). * With the added bonus of enabling PEP8 compliance in those sections. * Fixed remaining PEP8 compliance issues with the exception of the imports at the beginning of the file (changing those will break the entire module, so we'll cope with it as it is).
2018-06-28whitespace police:Ben McGinnes1-2/+2
* There's always one or, in this case, two.
2018-06-28python bindings: export secret keysBen McGinnes1-1/+42
* The holy grail: a function to export secret keys. * GPGME will still invoke pinentry and gpg-agent as usual to authorise the export. * Mostly similar to the two previous export functions for public keys except that it will return None if the result had a length of zero bytes. Meaning that the difference between the specified pattern (if any) not matching available keys and an incorrect passphrase is not able to be determined from this function (or the underlying one for that matter). Signed-off-by: Ben McGinnes <[email protected]>
2018-06-28python bindings: export public keysBen McGinnes1-6/+18
* Updated key_export and key_export_minimal to return None where a pattern matched no keys in a manner simnilar to the possible result of key_export_secret.
2018-06-28python bindings: export public keysBen McGinnes1-1/+58
* Added functions for exporting public keys to gpg.core in both complete form and in minimised form. * Rather than letting people need to worry about the export modes we are simply separating the functions as people would be more familiar with from the command line usage anyway. * Functions added for Context are: ctx.key_export_minimal and ctx.key_export as the default or full export. Signed-off-by: Ben McGinnes <[email protected]>
2018-06-17python bindings: core import statementsBen McGinnes1-3/+3
* Fixed the bit I broke while fixing the PEP8 compliance issues.
2018-06-17python bindings: core — PEP8 complianceBen McGinnes1-77/+101
* Fixed most of the PEP8 errors in core.py * Those remaining may need more than little edits and are a bit strange (too clearly the result of a programmer who has spent far too much time dealing with Lisp so that for Python it looks ... strange).
2018-06-17python bindings: core - key importgsoc/jacob-key-importBen McGinnes1-9/+37
* Wrapped the key import function in the try/exception statements needed to catch at least the most likely unsuccessful import attempt errors. * Mostly draws on the file error and no data import statuses for errors, with a couple of exceptions. Signed-off-by: Ben McGinnes <[email protected]>
2018-06-16python bindings: core key importBen McGinnes1-0/+19
* The foundation of a pythonic key import function authored by Jacob Adams. * A unit testing script for the same function originally authored by Tobias Mueller * Added DCO reference for Jacob Adams to the GPGME AUTHORS file. * Additional details regarding this patch are available here: https://dev.gnupg.org/T4001 Signed-off-by: Ben McGinnes <[email protected]>
2017-07-11python: Improve error handling.Justus Winter1-41/+67
* NEWS: Update. * lang/python/src/core.py (Context.__read__): New helper function. (Context.encrypt): Attach partial results to exceptions. (Context.decrypt): Likewise. (Context.sign): Likewise. (Context.verify): Likewise. * lang/python/src/errors.py (GpgError): Move the core of GPGMEError to this class, add a nicer interface for it. This makes the errors thrown by this library more uniform, and allows us to track the underlying error in synthesized high-level errors. (GPGMEError): Simplify. (...): Make sure to call the parent classes' constructor in all other classes. -- Attach partial results to errors. Some operations return results even though they signal an error. Of course this information must be taken with a grain of salt. But often, this information is useful for diagnostic uses or to give the user feedback. Since the normal control flow is disrupted by the exception, the callee can no longer return results, hence we attach them to the exception objects. GnuPG-bug-id: 3271 Signed-off-by: Justus Winter <[email protected]>
2017-04-07python: simplify build, some fixupsAlon Bar-Lev1-0/+0
* lang/python/gpg/version.py.in: Rename to lang/python/version.py.in. configure.ac: Generate version.py.in in lang/python. * lang/python/MANIFEST.in: Include version.py explicitly. * lang/python/gpg: Rename to 'src'. * lang/python/Makefile.am: Do not copy source files, do not use absolute directories, support lib64 in uninstall, clean also dist directory, use symlink for gpg src. * lang/python/setup.py.in: Use builddir, copy sources into builddir, copy version.py into module. -- Simplify build to symlink the gpg sources into builddir instead of copying. This requires handling of version.py as generated file. In addition apply some cleanups: Drop the absolution pathes, clean the dist directory as well, support lib64 for sitelib at uninstall. Signed-off-by: Alon Bar-Lev <[email protected]>
2017-03-21python: Wrap 'gpgme_op_keylist_from_data_start'.Justus Winter1-3/+20
* NEWS: Update. * lang/python/gpg/core.py (Context.keylist): New keyword argument 'source'. If given, list keys from 'source'. * lang/python/gpgme.i: Wrap the argument to 'gpgme_op_keylist_from_data_start'. * lang/python/tests/Makefile.am (py_tests): Add new test. * lang/python/tests/support.py (EphemeralContext): Do not throw an error if no agent has been started in the context. * lang/python/tests/t-keylist-from-data.py: New file. Signed-off-by: Justus Winter <[email protected]>
2017-02-17python: Support manipulating the TOFU policy.Justus Winter1-0/+12
* NEWS: Update. * doc/gpgme.texi: Fix typos. * lang/python/gpg/constants/__init__.py: Import new files. * lang/python/gpg/constants/tofu/__init__.py: New file. * lang/python/gpg/constants/tofu/policy.py: New file. * lang/python/gpg/core.py (Context.key_tofu_policy): New function. * lang/python/gpgme.i: Nice reprs for gpgme_tofu_info_t. * lang/python/setup.py.in: Install new package. * lang/python/tests/t-quick-key-manipulation.py: Extend test. Signed-off-by: Justus Winter <[email protected]>
2017-02-17python: Support quick key signing.Justus Winter1-0/+41
* NEWS: Update. * doc/gpgme.texi (gpgme_op_keysign): Fix the description of the 'expire' argument. * lang/python/gpg/constants/__init__.py: Import new file. * lang/python/gpg/constants/keysign.py: New file. * lang/python/gpg/core.py (Context.key_sign): New function. * lang/python/tests/Makefile.am (py_tests): Add new test. * lang/python/tests/t-quick-key-signing.py: New test. Signed-off-by: Justus Winter <[email protected]>
2017-02-17python: Fix using strings as commands in the assuan protocol.Justus Winter1-1/+1
* lang/python/gpg/core.py (Context.assuan_transact): Fix testing whether the command is a string on Python2. * lang/python/tests/t-protocol-assuan.py: Improve the test to detect this problem. Signed-off-by: Justus Winter <[email protected]>
2017-02-16python: Support adding and revoking UIDs.Justus Winter1-0/+24
* NEWS: Update. * lang/python/gpg/core.py (Context.key_add_uid): New function. (Context.key_revoke_uid): Likewise. * lang/python/tests/Makefile.am (XTESTS): Add new test. * lang/python/tests/t-quick-key-manipulation.py: New file. Signed-off-by: Justus Winter <[email protected]>
2017-02-16python: Support quick subkey creation.Justus Winter1-0/+72
* NEWS: Update. * lang/python/gpg/core.py (Context.create_subkey): New function. * lang/python/tests/Makefile.am (XTESTS): Add new test. * lang/python/tests/t-quick-subkey-creation.py: New file. Signed-off-by: Justus Winter <[email protected]>
2017-02-16python: Support quick key creation.Justus Winter1-1/+79
* NEWS: Update. * lang/python/gpg/constants/__init__.py: Import new file. * lang/python/gpg/constants/create.py: New file. * lang/python/gpg/core.py (Context.create_key): New function. * lang/python/tests/Makefile.am (XTESTS): Add new test. * lang/python/tests/support.py (TemporaryDirectory): New class. * lang/python/tests/t-quick-key-creation.py: New file. Signed-off-by: Justus Winter <[email protected]>
2017-02-15python: Update lists of functions returning gpgme_error_t.Justus Winter1-6/+18
* lang/python/gpg/core.py (Context._errorcheck): Add instructions how to update the list. Update list. (Data._errorcheck): Likewise. (Context.set_engine_info): Simplify. Signed-off-by: Justus Winter <[email protected]>
2017-02-14python: Wrap utility functions.Justus Winter1-0/+49
* NEWS: Update. * lang/python/gpg/core.py (pubkey_algo_string): New function. (pubkey_algo_name): Add docstring. (hash_algo_name): Likewise. (get_protocol_name): Likewise. (addrspec_from_uid): New function. * lang/python/gpgme.i (gpgme_pubkey_algo_string): Result must be freed. (gpgme_addrspec_from_uid): Likewise. Signed-off-by: Justus Winter <[email protected]>
2017-02-14python: Add keylist mode parameter.Justus Winter1-2/+5
* NEWS: Update. * lang/python/gpg/core.py (Context.keylist): Add 'mode' parameter. Signed-off-by: Justus Winter <[email protected]>
2017-02-14python: Add convenience functions for the home directory.Justus Winter1-2/+12
* NEWS: Update. * lang/python/gpg/core.py (Context.__init__): Add 'home_dir' argument. (__repr__): Include 'home_dir'. (Context.home_dir): New property. Signed-off-by: Justus Winter <[email protected]>
2016-12-01python: Make Context have a repr method.Tobias Mueller1-0/+8
* lang/python/gpg/core.py (Context.__repr__): New function. -- This makes Context objects look nicer in a REPL. Signed-off-by: Tobias Mueller <[email protected]>
2016-10-31python: Rename Python module from PyME to gpg.Daniel Kahn Gillmor1-15/+15
This follows weeks of discussion on the gnupg-devel mailing list. Hopefully it will make it easier for people using Python to use GnuPG in the future. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2016-10-13python: Make 'get_key' more idiomatic.Justus Winter1-1/+9
* lang/python/pyme/core.py (Context.get_key): Raise errors.KeyNotFound if the key is not found. This error is both a KeyError for idiomatic error handling as well as a GPGMEError so we don't break existing code. * lang/python/pyme/errors.py (KeyNotFound): New class. * lang/python/tests/support.py (no_such_key): New variable. * lang/python/tests/t-keylist.py: Test the new behavior. Signed-off-by: Justus Winter <[email protected]>