aboutsummaryrefslogtreecommitdiffstats
path: root/lang/python/src/core.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* python: Remove Python bindingsIngo Klöcker2025-02-031-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
* python,doc: Fix typos in documentation and source code commentsIngo Klöcker2023-10-131-3/+3
| | | | | | | | -- Anonymous contribution Signed-off-by: Ingo Klöcker <[email protected]>
* python: Don't call __del__ from __exit__ method.NIIBE Yutaka2022-08-091-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]>
* python: Don't access gpgme with wrapped=None.NIIBE Yutaka2022-08-051-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]>
* python: Reset passphrase callback correctly.Jasper Spaans2022-08-051-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]>
* python: Allow returning signatures made by unknown keys in `decrypt`Jasper Spaans2021-06-241-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
* python: Fix key_export*.NIIBE Yutaka2020-12-031-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]>
* python: Handle the when case __doc__ is None.NIIBE Yutaka2020-10-271-1/+6
| | | | | | | | | * lang/python/src/core.py (GpgmeWrapper): Check if None. -- GnuPG-bug-id: 5075 Signed-off-by: NIIBE Yutaka <[email protected]>
* Python, doc: Minor style improvementAndre Heinecke2019-05-061-8/+9
| | | | | * lang/python/src/core.py (Context): Retab and shorten max line length.
* python: stop raising BadSignatures from decrypt(verify=True)dkg/fix-T4276Daniel Kahn Gillmor2019-05-031-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]>
* python: overhaul logic of Context.decrypt()Daniel Kahn Gillmor2018-12-051-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]>
* python: ctx.decrypt() has problematic error handlingDaniel Kahn Gillmor2018-12-051-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]>
* python: Clarify the meaning of ctx.decrypt(verify=[])Daniel Kahn Gillmor2018-12-051-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]>
* python: gpg.Context.decrypt verify_sigs and sink_result are boolsDaniel Kahn Gillmor2018-12-051-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]>
* python: clarify documentation for verify argument for Context.decrypt()Daniel Kahn Gillmor2018-12-051-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]>
* python: simplify Context.decrypt()Daniel Kahn Gillmor2018-12-051-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]>
* python bindings: fixing decrypt-verifyBen McGinnes2018-09-301-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]>
* python bindings: ctx.decryptBen McGinnes2018-09-301-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]>
* python bindings: estreams fixben/estreams-fixBen McGinnes2018-08-301-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]>
* python bindings: coreBen McGinnes2018-08-291-6/+7
| | | | * lang/python/src/core.py: expanded gpgme_error check lists.
* python bindings: coreBen McGinnes2018-08-291-0/+1
| | | | | * lang/python/src/core.py: added gpgme_data_set_flag to the errorcheck funtion.
* python bindings: coreBen McGinnes2018-08-291-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.
* Python bindings src: PEP8 complianceBen McGinnes2018-08-181-1/+2
| | | | | * import namespace clearance for src/*.py. * Fixed a handful of is/is not None checks as well.
* PEP8 compliance and other code fixesBen McGinnes2018-08-101-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]>
* python bindings: scheming serpentsBen McGinnes2018-07-011-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.
* python bindings: gpg.coreBen McGinnes2018-07-011-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).
* whitespace police:Ben McGinnes2018-06-281-2/+2
| | | | * There's always one or, in this case, two.
* python bindings: export secret keysBen McGinnes2018-06-281-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]>
* python bindings: export public keysBen McGinnes2018-06-281-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.
* python bindings: export public keysBen McGinnes2018-06-281-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]>
* python bindings: core import statementsBen McGinnes2018-06-171-3/+3
| | | | * Fixed the bit I broke while fixing the PEP8 compliance issues.
* python bindings: core — PEP8 complianceBen McGinnes2018-06-171-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).
* python bindings: core - key importgsoc/jacob-key-importBen McGinnes2018-06-171-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]>
* python bindings: core key importBen McGinnes2018-06-161-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]>
* python: Improve error handling.Justus Winter2017-07-111-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]>
* python: simplify build, some fixupsAlon Bar-Lev2017-04-071-0/+1490
* 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]>