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 <justus@gnupg.org>
This commit is contained in:
parent
0ebd6a1b43
commit
7bc9cc717e
@ -29,7 +29,12 @@ copystamp: $(srcdir)/pyme $(srcdir)/helpers.c $(srcdir)/helpers.h
|
|||||||
if test "$(srcdir)" != "$(builddir)" ; then cp -r $^ . ; fi
|
if test "$(srcdir)" != "$(builddir)" ; then cp -r $^ . ; fi
|
||||||
touch $@
|
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) \
|
$(SWIG) -python -py3 $(SWIGOPT) \
|
||||||
-o $(builddir)/gpgme_wrap.c -outdir $(builddir)/pyme \
|
-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
|
$(PYTHON) $(srcdir)/setup.py build --verbose
|
||||||
|
|
||||||
clean-local:
|
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 \
|
if test "$(srcdir)" != "$(builddir)" ; then \
|
||||||
rm -rf pyme helpers.c helpers.h ; \
|
rm -rf pyme helpers.c helpers.h ; \
|
||||||
fi
|
fi
|
||||||
|
@ -259,7 +259,7 @@ PyObject* object_to_gpgme_t(PyObject* input, const char* objtype, int argnum) {
|
|||||||
%}
|
%}
|
||||||
%include "gpgme.h"
|
%include "gpgme.h"
|
||||||
|
|
||||||
%constant long EOF = GPG_ERR_EOF;
|
%include "errors.i"
|
||||||
|
|
||||||
// Generating and handling pointers-to-pointers.
|
// Generating and handling pointers-to-pointers.
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
from . import pygpgme
|
from . import pygpgme
|
||||||
|
from . import util
|
||||||
|
|
||||||
|
util.process_constants('GPG_ERR_', globals())
|
||||||
|
|
||||||
class GPGMEError(Exception):
|
class GPGMEError(Exception):
|
||||||
def __init__(self, error = None, message = None):
|
def __init__(self, error = None, message = None):
|
||||||
@ -43,8 +46,6 @@ class GPGMEError(Exception):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s (%d,%d)"%(self.getstring(), self.getsource(), self.getcode())
|
return "%s (%d,%d)"%(self.getstring(), self.getsource(), self.getcode())
|
||||||
|
|
||||||
EOF = getattr(pygpgme, "EOF")
|
|
||||||
|
|
||||||
def errorcheck(retval, extradata = None):
|
def errorcheck(retval, extradata = None):
|
||||||
if retval:
|
if retval:
|
||||||
raise GPGMEError(retval, extradata)
|
raise GPGMEError(retval, extradata)
|
||||||
|
Loading…
Reference in New Issue
Block a user