aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-05-24 15:22:08 +0000
committerJustus Winter <[email protected]>2016-05-24 16:00:16 +0000
commit7bc9cc717e428f48d4b27016f44c9f3900b1fba6 (patch)
tree23af4206eb2268aa8157b6354b2410feab22e520
parentpython: Move the base wrapper class. (diff)
downloadgpgme-7bc9cc717e428f48d4b27016f44c9f3900b1fba6.tar.gz
gpgme-7bc9cc717e428f48d4b27016f44c9f3900b1fba6.zip
python: Make all GnuPG errors available.
* lang/python/Makefile.am (errors.i): Generate file. * lang/python/gpgme.i: Include generated file. * lang/python/pyme/errors.py: Pull in all errors and error sources. Signed-off-by: Justus Winter <[email protected]>
-rw-r--r--lang/python/Makefile.am10
-rw-r--r--lang/python/gpgme.i2
-rw-r--r--lang/python/pyme/errors.py5
3 files changed, 12 insertions, 5 deletions
diff --git a/lang/python/Makefile.am b/lang/python/Makefile.am
index 86c19659..f58f0798 100644
--- a/lang/python/Makefile.am
+++ b/lang/python/Makefile.am
@@ -29,7 +29,12 @@ copystamp: $(srcdir)/pyme $(srcdir)/helpers.c $(srcdir)/helpers.h
if test "$(srcdir)" != "$(builddir)" ; then cp -r $^ . ; fi
touch $@
-gpgme_wrap.c pyme/pygpgme.py: gpgme.i gpgme.h copystamp
+errors.i:
+ sed -n -e \
+ '/GPG_ERR_[^ ]* =/s/ *\(.*\) = .*/%constant long \1 = \1;/p' \
+ `gpg-error-config --prefix`/include/gpg-error.h >$@
+
+gpgme_wrap.c pyme/pygpgme.py: gpgme.i errors.i gpgme.h copystamp
$(SWIG) -python -py3 $(SWIGOPT) \
-o $(builddir)/gpgme_wrap.c -outdir $(builddir)/pyme \
$<
@@ -38,7 +43,8 @@ all-local: gpgme_wrap.c pyme/pygpgme.py copystamp
$(PYTHON) $(srcdir)/setup.py build --verbose
clean-local:
- rm -rf -- build gpgme.h gpgme_wrap.c pyme/pygpgme.py copystamp
+ rm -rf -- build gpgme.h errors.i gpgme_wrap.c pyme/pygpgme.py \
+ copystamp
if test "$(srcdir)" != "$(builddir)" ; then \
rm -rf pyme helpers.c helpers.h ; \
fi
diff --git a/lang/python/gpgme.i b/lang/python/gpgme.i
index a82efb55..84bc6e98 100644
--- a/lang/python/gpgme.i
+++ b/lang/python/gpgme.i
@@ -259,7 +259,7 @@ PyObject* object_to_gpgme_t(PyObject* input, const char* objtype, int argnum) {
%}
%include "gpgme.h"
-%constant long EOF = GPG_ERR_EOF;
+%include "errors.i"
// Generating and handling pointers-to-pointers.
diff --git a/lang/python/pyme/errors.py b/lang/python/pyme/errors.py
index 5c8f9223..f716421e 100644
--- a/lang/python/pyme/errors.py
+++ b/lang/python/pyme/errors.py
@@ -17,6 +17,9 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from . import pygpgme
+from . import util
+
+util.process_constants('GPG_ERR_', globals())
class GPGMEError(Exception):
def __init__(self, error = None, message = None):
@@ -43,8 +46,6 @@ class GPGMEError(Exception):
def __str__(self):
return "%s (%d,%d)"%(self.getstring(), self.getsource(), self.getcode())
-EOF = getattr(pygpgme, "EOF")
-
def errorcheck(retval, extradata = None):
if retval:
raise GPGMEError(retval, extradata)